# MCP server

> Four Cad extraction and Rowe inference as Model Context Protocol tools. One URL, your API key as a bearer token, no SDK. Built for agent products that need engineering files as geometry, not captions.

Source: https://fourechelon.com/docs/mcp · Machine-readable: https://fourechelon.com/openapi.json · Index: https://fourechelon.com/llms.txt

## One URL, one header, no SDK

POST /api/mcp is a Model Context Protocol server over the Streamable HTTP transport in stateless JSON mode. Point any MCP client at it with your API key as a bearer token and Four Cad extraction and Rowe inference appear as tools. Every tool call is forwarded to the public REST route it mirrors, so authentication, billing, metering, rate limits, and idempotency are exactly the REST behaviour; nothing is billed twice or differently.

- URL: https://fourechelon.com/api/mcp
- Header: Authorization: Bearer fe_live_... (the same key as the REST API)
- Transport: JSON responses only; no sessions and no server-initiated streams, so it runs on serverless hosting

## Tools

Five tools. extract_cad, extract_cad_from_url, and rowe_respond are billed exactly like the REST routes they forward to, under the caller's API key, on 2xx only. list_models and list_supported_formats are free and need no key. Tool results carry a readable text summary plus the full JSON in structuredContent.

- extract_cad — file_name + content_base64 (+ target_contract) in; four-cad.extraction.v1 out. Text content is a readable summary (nodes, edges, relations, graph for draw.io; counts for CAD); structuredContent is the full JSON.
- extract_cad_from_url — same, but the server downloads a public http(s) URL first (25 MB, 20 s). Private and loopback addresses are refused.
- rowe_respond — the POST /api/v1/responses body as arguments: input.task_type plus cad_scene or point_cloud_scene.
- list_models — GET /api/v1/models: pricing, tasks, and whether the runtime is available now. Free.
- list_supported_formats — accepted extensions, target contracts, size limit. Free.

## What an agent gets from a draw.io file

The extraction keeps what a text dump loses: each node's absolute bounding box and container, each connector's source, target, and direction, derived spatial relations (contains, left_of, right_of, above, below, overlaps), and a graph summary (roots, sinks, isolated nodes, components, cycles). The same call handles STEP, IGES, DXF, PDF, and SVG.

## Agent skills

Three Agent Skills (the open SKILL.md format used by Claude Code, Cursor, Codex, Gemini CLI, and others) teach an agent when and how to use the API without an MCP connection: four-echelon-cad-extract (read a CAD, drawing, or diagram file as geometry), four-echelon-rowe (ask spatial questions), and four-echelon-diagrams (review or compare draw.io files as graphs). Install with npx skills add https://fourechelon.com; the index is at /.well-known/skills/index.json.

- npx skills add https://fourechelon.com
- Index: https://fourechelon.com/.well-known/skills/index.json
- Each skill states its trigger, credentials (FOUR_ECHELON_API_KEY, never printed), how to call, how to read the result, and what each error means

## Errors

A missing Authorization header on a billed tool returns HTTP 401 with a JSON-RPC error. REST failures (415 unsupported file, 402 payment required, 422 parse error, 503 converter unavailable) come back as tool results with isError: true and the REST error body in structuredContent, so the agent can read and recover from them.

```bash
# Claude Code
claude mcp add --transport http four-echelon https://fourechelon.com/api/mcp \
  --header "Authorization: Bearer fe_live_..."

# Any client config (Cursor, Windsurf, custom)
{
  "mcpServers": {
    "four-echelon": {
      "url": "https://fourechelon.com/api/mcp",
      "headers": { "Authorization": "Bearer fe_live_..." }
    }
  }
}

# Raw JSON-RPC
curl -s https://fourechelon.com/api/mcp \
  -H "Authorization: Bearer fe_live_..." -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"extract_cad","arguments":{"file_name":"cabinet.drawio","content_base64":"<base64>","target_contract":"structured"}}}'
```
