MCP server
Connect Claude, ChatGPT, Cursor, VS Code or your own agent to eContract with the Model Context Protocol
eContract runs a remote Model Context Protocol server. AI clients that speak MCP can send contracts for e-signature, follow signing, hand out signing links and fetch signed PDFs and audit trails, without custom code.
https://api.econtract.online/mcp- Transport: Streamable HTTP, stateless,
POST /mcp(protocol2026-07-28; clients that still start withinitializeare served too).GETandDELETE /mcpanswer405(after authentication). - Signing is always human. No tool signs or declines; the agent gives each signer their own link and the person signs.
Authentication
Every request needs Authorization: Bearer <token>, either:
- OAuth 2.1 (recommended for apps people connect): the client discovers everything from the server's
401answer and runs the OAuth flow in the browser. The user signs in, picks a workspace and approves the scopes. Tokens areeco_at_…and must be issued for the resourcehttps://api.econtract.online/mcp. - An API key
cl_live_…(headless agents, CI, CLI configs with a fixed header), created under Dashboard → API Keys.
A request without a valid token gets:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.econtract.online/.well-known/oauth-protected-resource/mcp", scope="contracts:read contracts:write templates:read files:read files:write ai:use"error="invalid_token" is added when a token was sent but is not valid. The protected resource metadata points to the authorization server https://api.econtract.online.
The MCP server checks every token with eContract and never forwards it; tool calls reach the contract API with the same identity, scopes and role cap as REST calls.
Tools
| Tool | Scope | What it does |
|---|---|---|
list_templates | templates:read | List workspace templates (search, category, type, page, limit) |
get_template | templates:read | A template and the variables to fill |
list_contracts | contracts:read | List contracts (status, search, fromDate, toDate, page, limit) |
get_contract | contracts:read | Status, processing status, signers and a nextStep hint. Accepts the id or the code (CTR-…) |
send_contract | contracts:write | Create and send in one step: one of file (base64 PDF/DOCX), fileUrl (https) or templateId + templateValues; signers, signingOrder, expiresInDays, delivery (email, link, both) |
get_signing_links | contracts:write | A fresh signing link for every signer who still has to sign. Sends no email |
send_reminder | contracts:write | Email pending signers again (all, or one signerId) |
void_contract | contracts:write | Cancel a contract (destructive) |
download_signed_document | contracts:read | The PDF as an embedded application/pdf resource (version: signed or original) |
get_audit_trail | contracts:read | Events, signers, hash-chain check and document SHA-256 |
verify_pdf | none | Check the digital signatures of any PDF (base64) |
analyze_contract | ai:use (+ contracts:read with contractId) | AI summary: type, parties, value, duration, suggested titles and signers, from text, contentBase64 or contractId |
Also a resource template econtract://contracts/{contractId}/document/{version} (contracts:read).
- Write tools take an optional
idempotencyKey. Without it the server generates one and returns it, so the model can repeat a call safely (see Idempotency). - Documents passing through the connector (uploads and downloads) are limited to 10 MB; larger files must be uploaded with
fileUrlor downloaded in the eContract app. - API errors come back as tool results with
isError: true, the errorcode,message,requestIdand a hint for the model.
Typical workflow
list_templates/get_template, or take the user's PDF or DOCX.send_contract, after confirming title, document and signers with the user. It returnsprocessingStatus: "processing".- Poll
get_contractuntilprocessingStatusisready. - With
delivery: "link"or"both":get_signing_links, and give each signer only their own link. - While waiting:
get_contract,send_reminder;void_contractto cancel. - When
statusiscompleted:download_signed_documentandget_audit_trail.
Connect your client
Server URL: https://api.econtract.online/mcp. OAuth clients only need the URL; they find the rest themselves.
Claude.ai and Claude Desktop
Settings → Connectors → Add custom connector, URL https://api.econtract.online/mcp, then Connect and approve the consent screen. (Menu names: verify against the current Claude UI.)
Claude Code
# OAuth (opens the browser on first use; or run /mcp inside Claude Code)
claude mcp add --transport http econtract https://api.econtract.online/mcp
# API key
claude mcp add --transport http econtract https://api.econtract.online/mcp \
--header "Authorization: Bearer cl_live_..."Project-scoped .mcp.json:
{
"mcpServers": {
"econtract": {
"type": "http",
"url": "https://api.econtract.online/mcp",
"headers": { "Authorization": "Bearer ${ECONTRACT_API_KEY}" }
}
}
}ChatGPT
Enable Developer mode (Settings → Apps & Connectors → Advanced), then Create a connector with URL https://api.econtract.online/mcp and authentication OAuth. (Menu names: verify against the current ChatGPT UI.)
Cursor
~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"econtract": { "url": "https://api.econtract.online/mcp" }
}
}Add "headers": { "Authorization": "Bearer cl_live_..." } to use an API key instead of OAuth. (Verify against the current Cursor docs.)
VS Code (GitHub Copilot agent mode)
.vscode/mcp.json:
{
"servers": {
"econtract": { "type": "http", "url": "https://api.econtract.online/mcp" }
}
}VS Code runs the OAuth flow when the server answers 401. For an API key add "headers": { "Authorization": "Bearer ${input:econtract-key}" } with a matching inputs entry. (Verify against the current VS Code docs.)
Your own agent or the MCP Inspector
Any MCP client with Streamable HTTP works. To try the tools by hand: npx @modelcontextprotocol/inspector, transport Streamable HTTP, URL https://api.econtract.online/mcp, header Authorization: Bearer cl_live_….
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
401 with WWW-Authenticate: Bearer resource_metadata=… | No token, or the client did not run OAuth | Reconnect; the client should follow resource_metadata. With an API key check the Authorization header |
401 with error="invalid_token" | Token expired or revoked, key revoked, user left the workspace, or an OAuth token issued only for the REST API | Let the client refresh or reconnect; OAuth clients must ask for resource=https://api.econtract.online/mcp |
400 invalid_request | Token sent in the URL (?access_token=) | Send it in the Authorization header only |
403 with WWW-Authenticate: Bearer error="insufficient_scope", scope="…" | The tool needs a scope the connection lacks | OAuth clients can re-authorize with the listed scope; for an API key add the scope under Dashboard → API Keys |
403 Forbidden: invalid Origin header | A browser client sent an Origin that is not allowed | Browser clients must run on an https origin (or http on localhost) |
429 with Retry-After (JSON-RPC error, data.code: "RATE_LIMITED") | More than 60 requests per minute for this key or connection | Wait Retry-After seconds |
503 with Retry-After: 5 | eContract could not check the token | Retry shortly |
Tool result isError: true, code HUMAN_ACTION_REQUIRED | The model tried to sign or decline | Give the signer their link from get_signing_links |
Tool result isError: true, code INSUFFICIENT_SCOPE or FORBIDDEN | Scope missing, or the user's workspace role does not allow it | Reconnect with the scope, or use an account with a suitable role |
download_signed_document fails with DOCUMENT_NOT_SIGNED | Not everyone has signed yet | Wait for status: "completed" |
| The client shows no eContract tools | Connection failed silently | Check the client's MCP log; test with the MCP Inspector and an API key |
OAuth 2.1
Let people connect your app or AI client to their eContract workspace with OAuth 2.1, PKCE, discovery and dynamic client registration.
Core Concepts
Core concepts of the eContract API, from workspaces and roles to the contract lifecycle, async document processing, signers, signing order and templates.