A MICP server exposes two endpoints, GET /v1/discovery and
POST /v1/call/{integration}.{account}.{method}, and always answers with the same envelope,
{ok, output}. The instructions below tell an agent how to use them. None of them puts a
credential in front of the model.
1Two functionsrecommended
For an agent with generic function calling: Hermes, or a harness of your own. The server is one; the integrations are many.
INTEGRATIONS, AND TWO FUNCTIONS
The server holds integrations. An integration is a service type. Inside each integration there are
accounts, one per connection. Each account enables the methods it may use.
This is the shape of what discovery answers:
email
elizeu -> send, list
suporte -> send
telegram
canal_curso -> send
Two functions expose it:
[
{
"type": "function",
"function": {
"name": "micp_discovery",
"description": "List the integrations this server holds, with their accounts and the methods each account may use, including the input and output of every method. Call it first, once per conversation, and again after a metodo_desconhecido error.",
"parameters": { "type": "object", "properties": {}, "additionalProperties": false }
}
},
{
"type": "function",
"function": {
"name": "micp_call",
"description": "Call one MICP method by its full name (integration.account.method). Returns {ok, output} on success or {ok: false, error, ...} on failure.",
"parameters": {
"type": "object",
"properties": {
"tool": { "type": "string", "description": "Exact method name from micp_discovery, with dots. Example: email.work.list" },
"input": { "type": "object", "description": "Only the fields the method declares in its input." }
},
"required": ["tool", "input"],
"additionalProperties": false
}
}
}
]
HOW TO WORK
You are connected to an integration server. You do not have direct access to those services.
An integration is a service type; an account is one connection inside it; a method is one operation.
Every callable name is integration.account.method.
1. Discovery first. Call micp_discovery before anything else. It returns
integrations[] -> accounts[] -> methods[], and every method carries name, input and output.
Only the names it returns exist. Never invent one.
2. Call. Use micp_call with the exact name and an input object:
{ "tool": "email.work.list", "input": { "query": "from:joao", "limit": 20 } }
- The name uses dots, not underscores: email.work.send, never email__work__send.
- The account is part of the name. There is no account field in input.
- Send only the fields the method declares. Extra fields are refused.
3. Read the envelope.
{"ok": true, "output": {...}}
{"ok": false, "error": "input_invalido", "campo": "to", "tentavel": false}
error What to do
input_invalido fix the field named in "campo" and retry once
nao_autorizado stop; this server may not call this method
metodo_desconhecido call micp_discovery again; the name is wrong
fornecedor 401/403: the credential is invalid, report it; 429/5xx: retry once
resposta_inesperada the service answered outside the contract; report it
output_invalido the pack is wrong; do not retry
Never retry when "tentavel" is false.
4. If a method declares a cursor field (for example page_token), pass it back unchanged to continue.
Keep every other field identical. The cursor is opaque and short-lived: use it in the
same turn, do not store it. No cursor in the answer means there is nothing more.
5. Do not assume. If a field is not in output, it does not exist. A high limit returns one
page, not everything.Put the JSON in your tool list and the text in the system prompt. The harness turns micp_call into POST /v1/call/{tool} with {"input": …}, the bearer token and an X-Request-Id.
2Shellno plugin
For an agent that can run shell commands but has no MICP tool: Hermes without the plugin, or any coding agent.
# Calling integrations through a MICP server
Use this when you need to act on real services (email, messages, spreadsheets) and a MICP
integration server is configured. The server exposes two endpoints: discovery and call.
## Setup (already done by the operator)
The environment holds two variables. Never print them and never write the token into a
command: let the shell expand it.
MICP_URL base URL of the server
MICP_TOKEN access token
Check before use:
[ -n "$MICP_URL" ] && [ -n "$MICP_TOKEN" ] && echo "MICP ready" || echo "variables missing"
## 1. Discovery, always first
curl -s -H "Authorization: Bearer $MICP_TOKEN" "$MICP_URL/v1/discovery" | python3 -m json.tool
Returns methods[] with name (integration.account.method), input and output.
Never invent a name: only the ones listed here exist.
## 2. Call, one POST
curl -s -X POST "$MICP_URL/v1/call/email.work.list" \
-H "Authorization: Bearer $MICP_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"input":{"query":"from:joao","limit":20}}'
Rules:
- The name goes in the path (/v1/call/{integration}.{account}.{method}), dots kept literal.
- The body carries only {"input": {...}}. No account, no URL, no headers.
- Only the fields the method declares in input. Extra fields are refused.
## 3. The response envelope
{"ok": true, "output": {"ids": ["18f2","18f19c"], "next": "0987"},
"output": {...}}
{"ok": false, "error": "input_invalido", "campo": "to", "tentavel": false}
error What to do
input_invalido fix the field named in "campo" and retry once
nao_autorizado stop; this token may not call this method
metodo_desconhecido go back to discovery; the name is wrong
fornecedor 401/403: invalid credential; 429/5xx: retry once
resposta_inesperada the service answered outside the contract; report it
output_invalido the pack is wrong; do not retry
Never retry when "tentavel" is false.
## 4. Continue a list
If a method declares a cursor field, repeat the same call with it set:
curl -s -X POST "$MICP_URL/v1/call/email.work.list" \
-H "Authorization: Bearer $MICP_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"input":{"query":"from:joao","limit":20,"cursor":"0987"}}'
- The cursor belongs to the query: keep the other fields identical.
- The cursor is opaque and short-lived: use it in the same cycle, do not save it for later.
- No next in the response means you are done.
## Pitfalls
1. Token in the prompt. Writing "Bearer eyJ..." into an instruction or a pasted command puts
the secret in the transcript. Always use $MICP_TOKEN and let the shell expand it.
2. Underscores in the name. It is not email__work__send. It is email.work.send, with dots.
3. Account in the body. There is no account field in input: the account is in the method name.
4. Asking for everything. A high limit does not return everything; it returns one page. Use the cursor.
5. Retrying permanent errors. An output_invalido repeats the same way forever.
6. Assuming fields that did not come back. If a field is not in output, it does not exist.
## Quick check
curl -s -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $MICP_TOKEN" "$MICP_URL/v1/discovery"Set the two variables in the agent's environment. Never paste the token into the prompt.
3Script or cronno agent
Nothing here requires a model. A scheduled job that publishes a report, or a back end that sends an invoice, uses the same two endpoints. Copy this into a shell script.
#!/bin/sh
# Two variables, in the environment. Never paste the token into the code.
# MICP_URL=https://integracoes.exemplo.pt
# MICP_TOKEN=***
set -e
# 1. what exists (once, when you write the script)
curl -s -H "Authorization: Bearer $MICP_TOKEN" "$MICP_URL/v1/discovery"
# 2. one call
curl -s -X POST "$MICP_URL/v1/call/email.elizeu.send" \
-H "Authorization: Bearer $MICP_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"input":{"to":"[email protected]","subject":"Diario","body":"Relatorio em anexo."}}'
# 3. read the envelope: {"ok":true,"output":{…}} or {"ok":false,"error":"…"}
# exit non-zero when ok is false, so the scheduler notices.The server records the call the same way it records one made by an agent: method, account, outcome and duration. Whether a model or a cron asked for it is a detail it notes and does not need to know.