Skip to content

MCP server ​

See CLI for the full environment reference; the MCP server uses the same variables and the same Worker API.

edge-spec-mcp is a local stdio MCP server. It exposes EdgeSpec to an MCP client such as Claude Desktop, Cursor, or another agent. It calls the configured Worker, so the pipeline, sandbox, and Workers AI binding stay in the deployment.

bash
bun run mcp -- --help

Client configuration ​

Use an absolute path to the server entry point:

json
{
  "mcpServers": {
    "edgespec": {
      "command": "bun",
      "args": ["/absolute/path/to/edge-spec/packages/mcp/src/index.ts"],
      "env": {
        "EDGESPEC_URL": "https://edge-spec.example.workers.dev",
        "GH_TOKEN": "ghp_...",
        "EDGESPEC_AI_PROVIDER": "openai",
        "EDGESPEC_AI_MODEL": "gpt-6-astra",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

For local development, point EDGESPEC_URL at http://127.0.0.1:8787 and start bun run dev:worker.

MCP uses stdio. Configure the client with the direct script path above, not bun run mcp: bun run prints its command banner to stdout, which would corrupt the JSON-RPC stream.

Tools ​

ToolSide effectsPurpose
edgespec_catalogRead-onlyProviders, models, defaults, sandbox availability
edgespec_scanRead-onlyGaps and repository overview
edgespec_generateCalls the AI providerGenerate and validate one test
edgespec_runCalls the AI providerGenerate and validate several tests
edgespec_prepare_pull_requestRead-onlyValidate files and issue a one-time approval token
edgespec_open_pull_requestWrites a branch and PRCommit the approved files

edgespec_generate and edgespec_run return the generated code and validation details. edgespec_run also returns the ready source paths and logs.

Opening a pull request is two-step. edgespec_prepare_pull_request returns an approvalId, an expiry and a readable summary; show that to the user. The client must then call edgespec_open_pull_request with only the token. Tokens expire after ten minutes and are consumed on first use.

Resources ​

URIContents
edgespec://gaps/{owner}/{name}Missing tests, contract gaps and totals
edgespec://specs/{owner}/{name}Parsed OpenAPI specs and artifact paths
edgespec://coverage/{owner}/{name}Coverage status and gaps from a scan
edgespec://runs/{id}Durable Workflow status for a webhook run

Resources are read-only and use the same environment credentials as the tools.

Environment ​

VariableMeaning
EDGESPEC_URLWorker URL; default http://127.0.0.1:8787
GH_TOKENPreferred GitHub token; GITHUB_TOKEN and EDGESPEC_GITHUB_TOKEN are legacy aliases
EDGESPEC_AI_PROVIDERDefault provider id
EDGESPEC_AI_MODELDefault model id
EDGESPEC_AI_KEYProvider key; overrides the provider-specific key
EDGESPEC_AI_BASE_URLBase URL for the private provider
CLOUDFLARE_ACCOUNT_IDAccount id for Workers AI BYOK
EDGESPEC_SANDBOX_URLTest runner URL
EDGESPEC_SANDBOX_KEYTest runner key
EDGESPEC_DEPLOYMENT_AI=1Use the deployment's Workers AI binding

Provider-specific keys such as OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, DEEPSEEK_API_KEY, MISTRAL_API_KEY, and OPENROUTER_API_KEY are also recognized.

Safety ​

  • Secrets live in the MCP client's environment, not in tool arguments or the conversation.
  • The server is local; it does not expose a public HTTP endpoint.
  • Scanning and resources are read-only. Generation costs an AI call. Opening a pull request writes to GitHub and is gated by a one-time approval token from edgespec_prepare_pull_request.
  • Validation is honest: without a sandbox runner the result says static check only, not executed.

Generated tests are a draft, not a proof.