mcp-tools-surface
Exposes every query and mutation of a GraphQL schema as an MCP tool, executing operations through graphql-command-runner and returning generated responses with links represented as IDs.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-tools-surface
Status: vibecoded, not reviewed. Written by Claude, an AI coding agent, in one unattended session from a brief; no human has read the code. It has tests through the MCP SDK's own client and raw sockets, against a real command runner on PostgreSQL 18, but treat it as unaudited: this is where the token check and the scope challenge are enforced for MCP. Details in AI-DECLARATION.md.
The MCP endpoint of a service: each query and mutation of its GraphQL schema
is one MCP tool, served over stateless Streamable HTTP with the official MCP
TypeScript SDK 2 (@modelcontextprotocol/server 2.4.0 and
@modelcontextprotocol/node 2.1.2, pinned). It serves both protocol eras the
SDK serves: the 2025 initialize handshake (through the SDK's stateless
fallback) and the 2026-07-28 per-request revision. A tool call runs the
operation's generated response document through
graphql-command-runner's execute; nothing calls
a resolver. It verifies no tokens itself: the token check comes from
jwt-tenant-auth, and the input schemas from
graphql-input-json-schema.
Mount interface
import { createMcpSurface } from 'mcp-tools-surface';
const mcp = createMcpSurface({
runner, // from createCommandRunner
tokenCheck, // from createTokenCheck: authenticate and authenticateInTenant
serviceName: 'shelf', // scopes shelf:read and shelf:write; also the MCP server's name
resourceMetadataUrl: 'https://shelf.example.org/.well-known/oauth-protected-resource/mcp',
maxRequestBodySize: 1024 * 1024, // the default
logger, // { error, warn }; console by default; one that throws is ignored
});
// In the host's router:
if (path === mcp.path) return mcp.handle(req, res); // mcp.path is '/mcp'
// handle serves any request it is given, so route only that exact path to it.
// And on the server, so that Node doesn't answer `Expect: 100-continue` itself:
server.on('checkContinue', route);function createMcpSurface(options: McpSurfaceOptions): McpSurface;
interface McpSurfaceOptions {
runner: Pick<CommandRunner, 'schema' | 'operations' | 'execute'>;
tokenCheck: Pick<TokenCheck, 'authenticate' | 'authenticateInTenant'>;
serviceName: string;
resourceMetadataUrl: string;
maxRequestBodySize?: number;
logger?: Logger;
}
interface McpSurface {
readonly path: '/mcp';
handle(req: IncomingMessage, res: ServerResponse): void | Promise<void>;
}The host serves the login discovery document (the protected-resource
metadata); resourceMetadataUrl is its absolute address, at the public origin
the settings give, and every challenge points at it. createMcpSurface throws
a TypeError naming every problem with the options, including an operation
whose arguments can't be described (a custom scalar it doesn't know, a
recursive input type).
Exports: createMcpSurface, MCP_PATH ('/mcp'), SCALAR_WIRE_FORMS,
TENANT_ARGUMENT ('tenant'), and the types
McpSurfaceOptions, McpSurface, Runner.
Related MCP server: GraphQL MCP Server
Tools
One tool per operation, named after it, described by its description in the schema. The server's instructions are the schema's own description.
Input schema: exactly the operation's arguments, as JSON Schema with every input type written out in full (no
$ref), from graphql-input-json-schema. The framework scalars are strings:Datewithformat: date,DateTimewithformat: date-time,DecimalandCursorplain. A mutation the schema doesn't declare idempotent also has the optionalidempotencyKeythe runner adds to it. The SDK checks a call's arguments against this schema (unknown arguments included) and refuses a mismatch as a tool error; the runner checks every value again.Hints:
readOnlyHintfor a query;destructiveHintfor a mutation with@effect(kind: DESTRUCTIVE);idempotentHintfor a query and for a mutation with@effect(idempotent: true).Result: one text block holding the generated response as JSON: the fields the runner's one rule picks, with each link (an entity inside another entity) as the linked entity's bare ID, and a list of links as a list of IDs (the runner's
withLinksAsIds).
Outcome | Tool result |
Ran | the generated response as JSON; |
A declared error in the payload |
|
A query for one record (a nullable entity) that found none |
|
Bad input, a role not allowed, an unexpected failure (from the runner) |
|
Arguments that don't fit the input schema |
|
A tenant problem (below) |
|
The tenant argument
For a caller whose token lists more than one tenant, every tool also takes an
optional tenant argument: a string whose description and examples list
the token's tenants. It is not an enum: like the Tenant-Id header it takes a
tenant ID in any case, and the token check refuses one the token doesn't list.
A caller in one tenant gets no such argument, and a call that sends one is
refused like any unknown argument.
Named: the call runs in that tenant, through jwt-tenant-auth's
authenticateInTenant(the same token check). If the request'sTenant-Idheader names another tenant, the call is refused as bad input; the same tenant in both is fine.Not named: the call runs in the tenant the token check chose for the request: the
Tenant-Idheader's, else the token's default, else its only tenant. A token that lists several tenants and marks none, on a request with no header, still lists the tools; a call that names no tenant is then refused as bad input.
Challenges and refusals before the body
Everything in this table is answered from the request's headers, before the
SDK sees the request or any of the body is read, with Connection: close;
the connection is destroyed once the answer is written.
Request | Answer |
No | 401, |
A token that isn't valid (forged, expired, another audience or issuer, no user) | 401, |
A token listing no tenant, or a default it doesn't list, or a | 403, JSON-RPC error body ( |
A malformed | 400, JSON-RPC error body (code |
The token check throws (issuer keys unreachable) | 500, |
A stated | 413, JSON-RPC error body |
The scope challenge. A query needs <svc>:read and a mutation
<svc>:write, granted by exactly that name. A tool call without it gets, before
the call runs:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", error_description="This tool needs the shelf:write scope.", scope="shelf:write", resource_metadata="<url>"This is the SDK's per-tool scopeChallenge; the surface resolves the
caller for the call first (tenant argument included), so the challenge is
built from the token's own scopes. A call that can't run anyway (no tenant
chosen, a tenant the token doesn't list) gets its tool error instead.
Listing tools needs no particular scope.
The forms follow the MCP authorization specification, revision 2026-07-28: https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization (sections "Scope Selection Strategy", "Error Handling" and "Scope Challenge Handling"), with RFC 6750 section 3 (https://datatracker.ietf.org/doc/html/rfc6750#section-3) and RFC 9728 (https://datatracker.ietf.org/doc/html/rfc9728).
Limits
Body: 1 MiB by default (
maxRequestBodySize). A stated length over it is refused from the headers, before any100 Continue. A body with no stated length is cut off by the SDK's Node adapter (itsmaxRequestBodySize), which answers 413; the surface closes the connection after that answer. A client still sending may see a reset instead of the 413. A caller that goes away mid-body is not logged.Batches: one JSON-RPC message per request. A JSON array body is refused with 400 (code
-32602) before any of it runs, in either era.Expect: 100-continue: the surface sends100 Continueitself, and only once the token check and the stated length have passed. This needs the server'scheckContinueevent routed tohandle.Pipelining: requests on one connection are handled in turn with node-http-refusal's
admitRequest(which also puts the token check before any100 Continue), so nothing pipelined behind a refusal runs.How long a body may take is the host's
requestTimeout.
Stateless
A fresh McpServer is built for each HTTP request, and nothing is kept
between requests: no session IDs, GET for a server stream is answered 405,
and subscriptions/listen (2026-07-28) is refused at once with the SDK's
Subscription limit reached (the subscription cap is 0). Tools never send
notifications, so every answer is a single JSON body or an SSE stream that
ends with the request.
Tests
npm install
npm test # checks the sibling copies, builds, type-checks, runs every testThe tests start one embedded PostgreSQL 18 cluster per run (copied from
graphql-command-runner's test/support/cluster.ts), give each file its own
database with a small shelf service (test/fixtures/shelf), and run
jwt-tenant-auth's real token check against its local issuer. Tool calls go
through @modelcontextprotocol/client 2.4.0, in both eras; refusals and the
body limit are also checked over raw sockets. They need Node 24 or later for
--test-global-setup.
The siblings are installed as copies (install-links=true), so every
package shares one copy of graphql. After rebuilding a sibling, run
npm run refresh-siblings; npm test refuses to run against stale copies.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Query, browse, and automate OmegaAI workspaces from any MCP client. Streamable HTTP with OAuth 2.0.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
Streamable HTTP MCP gateway for NV oOS fleets — one API key, namespaced tools, quotas and policy.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP that can proxy any GraphQL API and expose graphql operations as mcp tools.57 npm18Apache 2.0
- AlicenseNot gradedqualityCmaintenanceAutomatically discovers and exposes any GraphQL API as MCP tools with zero configuration.129 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceMCP server that exposes GraphQL operations as typed tools for AI models, with schema exploration, validation, execution, hot reload, OAuth, prompts, MCP Apps widgets, and OpenTelemetry support.MIT
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients to interact with a fixed business GraphQL API as typed, safely guarded tools, including JWT authentication, rate limiting, and query/mutation protections.-