Skip to content

Latest commit

 

History

History
107 lines (85 loc) · 6 KB

architecture.md

File metadata and controls

107 lines (85 loc) · 6 KB

Noderings MCP — Architecture

Purpose

mcp-noderings is a Model Context Protocol server that exposes curated Noderings capabilities to MCP clients (Cursor, Claude Desktop, etc.). It is an adapter in front of the Noderings gRPC API, not a new product backend.

Layering

MCP Client
  → Transport (stdio | streamable-http | SSE)
  → HTTP caller auth (HTTP transports only)
  → MCP protocol adapter (mcp-go)
  → Tool layer (typed inputs/outputs)
  → Application / service layer
  → Buf-generated gRPC client (or HTTP-gateway fallback)
  → Noderings gRPC server / HTTP gateway

Transports share one tool and service layer. Tool handlers consume an already- authenticated context.Context only; they do not implement transport auth.

Decisions (approved defaults)

ID Decision Reason
Q1 github.com/mark3labs/mcp-go Matches Grafana MCP; stdio + streamable-http + SSE
Q2 Shared bearer is the default HTTP caller auth (server-auth-token); OAuth 2.1 (http.authMode: oauth) is opt-in OAuth verifies Noderings-issued JWTs (JWKS, iss, RFC 8707 aud, exp) and the SA impersonates the user. Modes are mutually exclusive
Q3 v1 read-only tools; writes gated by --disable-write (default on) Least privilege / context window
Q4 Chart is deploy/helm/noderings-mcp production: true requires image.digest (sha256:…)
Q5 Module github.com/noderings/mcp Public path; not module backend
Q6 Default replicaCount=1, HPA off; multi-replica requires sessionAffinity.enabled SessionBinder is process-local; not official-SDK stateless
Q7 Env prefix NRMCP_ Avoid collision with backend NR_
Q8 Opt-in OTLP HTTP traces; Prometheus remains the metrics path Default off. No secrets in spans
Q9 GET /.well-known/oauth-protected-resource is 404 in shared-bearer; RFC 9728 metadata in oauth mode 401s in oauth mode carry WWW-Authenticate: Bearer resource_metadata=…
Q11 GET /.well-known/mcp.json is public discovery metadata (name, endpoint, icon). No token and no tool list. Host and Origin checks still apply Directories fetch this path before connecting. The endpoint is http.oauth.resource when set, so the document does not echo the request Host
Q10 gRPC when grpcAddress is set; HTTP gateway only if that address is empty Proto is the contract; HTTP uses proto google.api.http paths, not frontend OpenAPI

API contract

  • Public contract: vendored proto/v1, generated with Buf into gen/proto/v1.
  • Maintainer sync: make proto-sync from a backend checkout, then make generate. See generate.md.
  • Vendored surface: client, provider, IAM, and subscription, with VNC, password, Stripe Connect, payout, and Proxmox CPU fields removed. Gameserver, notification, and roadmap are dropped. See generate.md.
  • Do not use frontend npm run api:update / openapi.v3.json for Go types.
  • Do not import backend/....

Authentication

Two distinct credentials (never passthrough):

  1. MCP caller credential (HTTP/SSE only), one mode per process via http.authMode:
    • shared-bearer (default): secret compared to serverAuthToken / serverAuthTokenFile (one ≥32-char secret per line; prefer one per client). Required for every HTTP bind, including loopback.
    • oauth (opt-in): Noderings-issued JWT access token verified against http.oauth.jwksURL (iss, RFC 8707 aud = http.oauth.resource, exp). user_id, org_id, org_type come from claims. Every MCP request, initialize and tools/list included, requires the JWT and answers 401 with WWW-Authenticate without one. GET /.well-known/oauth-protected-resource and GET /.well-known/mcp.json are the only public paths. http.oauth.allowAnonymousDiscovery: true (off by default) lets initialize, notifications/initialized, ping, and the */list methods answer without a token so a directory can index the catalog; tools/call still needs the JWT, an unauthenticated GET is 405, and the first valid token adopts the discovery session.
  2. Noderings SA token: opaque JWT from TOKEN / TOKEN_FILE, sent only as gRPC metadata or HTTP Authorization: Bearer …. Shared-bearer adds optional x-organization-id (pinned org). OAuth adds x-acting-user-id and x-organization-id from the verified token (impersonation: backend authorizes as that user/org). The caller's token is never forwarded. The HTTP-gateway path is used only when backend.grpcAddress is empty.

stdio trusts process/environment (MCP spec); logs go to stderr.

Tools

Curated snake_case tools by category (identity, vms, dns, tickets, catalog, provider). No generic call_api. No progressive search_tools in v1.

Write tools (create_virtual_machine, update_virtual_machine_power, delete_virtual_machine, create_snapshot, create_dns_zone, upsert_dns_record, upsert_dns_geo_record, delete_dns_geo_record, create_ticket, create_network, create_prefix, add_reserved_ip, remove_reserved_ip, update_node_placement_policy, create_vm_template, create_plan) are registered only when tools.disableWrite is false (default true). VM create uses SSH key IDs only. create_dns_zone creates a blank apex zone (no record import). upsert_dns_record maps to proto UpsertDnsRecord and is create-only unless allow_overwrite is true. upsert_dns_geo_record maps to UpsertDnsGeoRecord with the same create-only default.

HTTP Host/Origin allowlists must not contain *. Tool concurrency is capped by limits.maxConcurrentTools.

Security review: security-review.md.

Status

Writes default off. OAuth is opt-in; shared-bearer remains the default. Optional live gRPC tests run only with NRMCP_IT=1.

References