The MCP server
MADATA speaks the
Model Context Protocol. An AI
assistant connects to the single address
https://mcp.madata.africa/mcp, your code to the address of your
workspace, and both call the same business tools.
01What it is
The MCP server is the second façade over the tool engine of Mia, the built-in assistant. Where Mia runs its loop internally, the MCP server publishes its tools to an external client: Claude, ChatGPT, Gemini, Mistral Le Chat, or your code.
The client receives a tool catalog (tools/list), calls
tools (tools/call), and reads read-only resources. Every call
runs with the permissions of the connected user.
02Two addresses, one server
| Address | For | Authentication |
|---|---|---|
https://mcp.madata.africa/mcp | Claude, ChatGPT, Mistral Le Chat, Claude Code. | OAuth 2.1. You pick the workspace when signing in. |
https://<workspace>.madata.app/mia/mcp | Scripts, Gemini CLI, Cursor, VS Code, a GPT Action. | Bearer mia_… key. The workspace OAuth stays available. |
mcp.madata.africa is a gateway: it hosts the OAuth
authorization server, then relays each request to the server of the chosen
workspace. Tools, permissions, limits and errors are therefore those of the
workspace.
The gateway only accepts the
tokens it issued: a key created in the portal gets 401 there. With a
key, always call the workspace address.
03Endpoint & transport
- Method
POST: JSON-RPC 2.0 body, one request per call- Auth
Authorization: Bearer …header- Content-Type
application/json- Body
- 8 MB at most
The transport is plain HTTP, compatible with modern "Streamable HTTP" clients. There is no server→client SSE stream, and the server is stateless:
| HTTP method | Response | Role |
|---|---|---|
POST | 200 + JSON-RPC body | Main channel: all protocol methods. A notification gets 202 with no body. |
GET | 405 | Would open a notification stream; the server has none. |
DELETE | 204 | End of session; stateless server, no effect. |
OPTIONS | 204 + CORS | Preflight (extensions, web clients). Access-Control-Allow-Origin: *. |
04Handshake (initialize)
The first call of any session. The server returns the requested protocol
version if it is supported (2025-11-25, 2025-06-18,
2025-03-26, 2024-11-05), otherwise
2025-06-18. Every response repeats the version in the
MCP-Protocol-Version header.
{"jsonrpc":"2.0","id":1,"method":"initialize",
"params":{"protocolVersion":"2025-06-18","capabilities":{},
"clientInfo":{"name":"my-app","version":"1.0"}}}
{"jsonrpc":"2.0","id":1,"result":{
"protocolVersion":"2025-06-18",
"capabilities":{"tools":{},"resources":{},"prompts":{}},
"serverInfo":{"name":"madata-mia","version":"1.2.0","title":"Madata",
"websiteUrl":"https://<workspace>.madata.app","icons":[…]},
"instructions":"Cette plateforme de gestion d'entreprise s'appelle Madata…"
}}
The instructions field reminds the client to call the
platform "MADATA", to act through the tools rather than sending the user to the
UI, and to suggest "Read + Write" if no write tool shows up.
05Protocol methods
| Method | Role |
|---|---|
initialize | Version negotiation, capabilities, serverInfo. |
notifications/* | Acknowledgement: 202 with no body. |
tools/list | Tool catalog, filtered by the scope of the connection, with a readable title and annotations. |
tools/call | Runs a tool. |
resources/list · resources/read | 4 read-only resources (see Resources). |
resources/templates/list | Returns an empty list (no URI templates). |
prompts/list · prompts/get | 8 ready-to-use prompts. |
ping | Returns {}. |
Any other method (logging/setLevel, completion/complete,
roots/list…) returns the JSON-RPC error -32601
"method not found" with HTTP 200: this is normal
discovery, not a failure. JSON-RPC batches (arrays) are not supported.
06Calling a tool (tools/call)
{"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"get_kpi","arguments":{"period":"month"}}}
{"jsonrpc":"2.0","id":2,"result":{
"content":[{"type":"text","text":"{\"ca_ttc\":4210000,…}"}],
"isError":false
}}
The result comes back in content: a text block in
compact JSON, and a resource block for a generated file. When the
user has access to several companies, write tools also declare a
company_name parameter.
A tool response is 96 KB at most. Beyond
that, its longest list is shortened and a _tronque field says how many
items are kept out of the total: narrow the filter, request fewer fields or
paginate.
When a call succeeds but the answer is
"not found", "argument to fix", "empty target" or "forbidden",
isError stays false: the response carries usable
information (near matches, the field name to correct, where to widen the
connection). The client uses it instead of replaying the same call verbatim.
07Error codes & status contract
The distinction matters for an AI connector: a 401 makes it drop its token and restart an OAuth consent; a 403 keeps it connected and it retries.
| Situation | HTTP | JSON-RPC | Headers / detail |
|---|---|---|---|
| Key missing / invalid / expired / revoked | 401 | -32001 | WWW-Authenticate: Bearer resource_metadata="…" |
| Mia disabled on the workspace | 403 | -32001 | Retry-After: 300 |
| Mia subscription inactive | 403 | -32001 | Retry-After: 300 |
| Billed resource touched | 403 | -32003 | Business message: "manage this in the portal". |
| Rate limit exceeded | 429 | -32029 | Retry-After: 60 |
| Body over 8 MB | 413 | -32600 | |
| Unknown protocol method | 200 | -32601 | Normal discovery. |
| Unknown tool or prompt, wrongly typed parameter | 200 | -32602 | |
| Unknown or unauthorized resource | 200 | -32002 | |
| Tool execution error | 200 | result with isError:true | |
| Internal failure | 500 | -32603 | Generic message, details in the log. |
| Unparseable JSON | 400 | -32700 | |
Batch, missing method, workspace not found | 400 | -32600 |
The gateway adds its own responses, in the
{"error":"…","error_description":"…"} format:
| Situation | HTTP | Detail |
|---|---|---|
| Token missing, expired, revoked or unknown | 401 | WWW-Authenticate: Bearer resource_metadata="https://mcp.madata.africa/.well-known/oauth-protected-resource" |
| Access removed in the workspace | 401 | The workspace answered 401: the link is cut, sign in again. |
| Body over 20 MB | 413 | payload_too_large |
| Workspace unreachable | 502 | espace_injoignable: retry. |
| Workspace unavailable | 503 | espace_indisponible |
08Rate limit
120 requests / minute per user and per workspace, sliding
window. Handshake and catalog methods (initialize,
tools/list, prompts/list, resources/list,
resources/templates/list, ping) do not
count; calls (tools/call, resources/read,
prompts/get and the REST route) are capped. Over the limit →
429 + Retry-After: 60.
09Scope & permissions
Three levels combine:
- Connection scope:
read_only,full_access(read + write) orcustom(an allow-list of tools). It can be changed at any time in the portal, Mia page, MCP tab. - The user's access mode, set in the portal ("Read only" or "Read and write"): a "Read only" user never writes, whatever the scope.
- The user's permissions in the workspace: a tool the
user is not allowed to use, or whose module is hidden from them, does not appear
in
tools/list.
Whatever the scope, a connection can never create or
modify billed resources: users, companies, points of sale,
apps. Any attempt returns -32003. No point asking to raise
permissions: that is not where the refusal comes from.
10Availability
MCP access requires an active Mia subscription on the workspace. Without one,
the MADATA page refuses the authorization. If the subscription stops later, the
server replies 403 + Retry-After: the connection stays
and access comes back as soon as it is reactivated, with nothing to redo.