Circulara Observe MCP Plugin

Circulara Observe MCP Plugin

Provides Claude Code integration to capture LLM usage events and surface cost, carbon, and savings reports via tools and hooks.

Category
访问服务器

README

circulara-core

Circulara Observe tier: per-tenant backend + MCP plugin. Sprints 1-4: WS0 (scaffold), WS6 (pricing registry), WS1 (MCP plugin), WS2 (auth + BYO keys + gateway), WS3 (telemetry pipeline: normalize -> re-price -> append; free-tier cap; OpenAI-format gateway for Cursor-class hosts), WS4 (meter compute: registry pricing, energy/CO2e ranges with confidence labels, per user/team/module/month report), WS5 (Observe dashboard + savings-potential report + monthly statement, server-rendered, Ledger Light brand tokens; seed a demo tenant with packages/backend/scripts/seed-demo.ts and open the printed /dashboard URL). Architecture: /outputs/reports/architecture_v1.md (AD1-AD6, rev 2026-07-07) + the sourcing addendum (AD7-AD12).

Pricing placement: the meter owns money. All three capture paths (hook, tool, gateway) deliver tokens + model; pricing happens ONCE in the WS3/WS4 pipeline from the approved registry snapshot. Client-submitted observe events are re-priced server-side; client cost is a hint, never the booked number. Engine-computed events (reuse/sourcing, waves 3+) carry their own math and are born meter-priced in-process.

Workspace layout

Package What
packages/schema THE event schema (zod, v1.0+v1.1, AD4/AD12 incl. call_id + M1 stacking rule). Single source of truth for backend intake AND plugin emission
packages/backend Per-tenant backend: tenancy/isolation (PGlite+pgvector dev, per-tenant Postgres prod), append-only meter, seats (AD6), WS2 auth (OIDC + short-lived agent tokens + dev mode), BYO provider keys envelope-encrypted at rest, gateway metering mode (AD3-B, M2 per-seat credentials), object store, WS6 pricing registry + carbon coefficients
packages/plugin MCP plugin (AD3 path C tools: circulara_report, circulara_status) + Claude Code PostToolUse hook (path A observe capture). Validates events against the shared schema BEFORE sending

Run

npm install
npm test              # all workspaces: backend 11 + plugin 4 (in-memory, no keys)
npm run typecheck
npm run dev           # backend on 127.0.0.1:8787 (CIRCULARA_AUTH_MODE=dev|oidc)

# WS6 registry flow (human approves diffs, D12):
npm run registry -- update|approve|show

# WS2 LIVE smoke (deliberate; ~cents on the configured Anthropic key):
cd packages/backend && npx tsx scripts/live-smoke.ts

Auth (WS2)

  • Humans: OIDC/SSO (RS256 vs org issuer JWKS; admin via circulara_role=admin claim).
  • Named agents: short-lived HS256 seat tokens minted at POST /v1/seats/:id/token (admin).
  • Dev mode ONLY with CIRCULARA_AUTH_MODE=dev: Bearer dev-admin-token / dev-seat-token.
  • Gateway (M2): per-seat credentials from POST /v1/seats/:id/gateway-credential; the host sends the credential as x-api-key to POST /gateway/anthropic/v1/messages; backend maps credential -> seat, forwards on the tenant's real key, meters per seat.

MCP plugin install (Claude Code)

claude mcp add circulara \
  -e CIRCULARA_BACKEND_URL=http://127.0.0.1:8787 \
  -e CIRCULARA_TENANT_ID=<uuid> -e CIRCULARA_TOKEN=<bearer> \
  -e CIRCULARA_SEAT_ID=<uuid> -e CIRCULARA_USER_ID=<sso-subject> \
  -- npx tsx <repo>/packages/plugin/src/server.ts

Hook capture (path A): wire packages/plugin/src/hook.ts as a PostToolUse hook (see file header). The hook never fails the host tool call.

Invariants the tests enforce

  • Tenant isolation; append-only meter_events; admin-only agent seats (AD6).
  • avoided_usd == counterfactual - actual; sourcing types require the v1.1 block; M1 call_id chaining telescopes per-call savings.
  • Provider keys never at rest in plaintext (envelope AES-256-GCM, wrong-KEK/tamper throw); write-only API (names listed, values never returned).
  • Gateway: unknown credential 401; missing tenant key 503; per-seat attribution exact; registry-priced usage.
  • OIDC: wrong issuer rejected; dev tokens rejected outside dev mode; agent tokens expire.

Keys

Runtime keys come ONLY from the external env file via loadSecret() (path in src/config.ts, names in /context/api.md): CIRCULARA_MASTER_KEY (envelope KEK), CIRCULARA_AGENT_TOKEN_SECRET (agent JWTs), tenant provider keys via the API. Never hardcoded, never logged, never committed.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选