Developers · MCP
Connect Foral to your AI assistant (MCP)
The Model Context Protocol (MCP) lets AI assistants — Claude, Cursor, ChatGPT and others — call Foral directly as tools. Foral has three connections: one main connection (Beta) to every agent and data service you may use, a narrow connection for a single company agent, and the Data API connection for Premium accounts.
1. Connect once to Foral (Beta)
One address — https://agents.foral.ai/mcp — gives your AI assistant the Foral agents and data that your account may use. You sign in once, choose what the connection may reach, and start. You do not copy a separate key for each agent you buy.
The connection gives access to read services only. It never gives more than your rights: every call is checked again against your current subscriptions, memberships and consent.
| What | Value |
|---|---|
| Address | https://agents.foral.ai/mcp |
| Transport | Streamable HTTP: one JSON-RPC message per POST, JSON responses |
| Sign-in | OAuth (Claude, ChatGPT), or a scoped integration key fik_… for local and command-line clients |
| Reach | The agents and data allowed by your consent, your subscriptions and your role |
Claude
- claude.ai and Claude Desktop: Customize → Connectors → Add → Add custom connector. Enter a name and the address above, click Add, then Connect. Foral opens: sign in, choose the accounts and workspaces, and approve.
- Claude Code: run the command below, then run
/mcpinside Claude Code and chooseforalto sign in. You can also put the JSON block in.mcp.json. - Claude can send a fixed header with a key, but one fixed header is ONE shared credential: if a team shares that connector, every user acts as the same credential. Prefer OAuth, so that each person signs in.
Claude Code
claude mcp add --transport http foral https://agents.foral.ai/mcp
# then, inside Claude Code, run /mcp and choose "foral" to sign in to Foral.mcp.json (OAuth, no key in the file)
{
"mcpServers": {
"foral": {
"type": "http",
"url": "https://agents.foral.ai/mcp"
}
}
}ChatGPT
ChatGPT: Plugins → Add → Add custom MCP server. Enter a name and the address above, keep Authentication on OAuth (ChatGPT registers itself), accept the risk notice and click Create as a plugin, then Continue. Foral opens: sign in, choose the accounts and workspaces, and approve.
This surface of ChatGPT has no option for a custom API key. Use OAuth. The OAuth client ID and secret that ChatGPT uses identify the app, not you; they are not a Foral key.
Local and command-line clients, and integration keys
A local client or a script can sign in with OAuth, or send a scoped integration key. The key starts with fik_. You create it in your account settings (a personal key) or in the settings of a workspace (a workspace key; you need the permission to create it). Foral shows the key once: copy it then.
When you create the key, you choose its channels (MCP, A2A or both). One key can cover several subscriptions without becoming unrestricted. You can revoke it at any time.
Send the key only in Authorization: Bearer fik_…. Never put it in a URL, in tool arguments or in a prompt. In a config file, read it from an environment variable, as below. A key does not work on the Foral Data server (data.foral.ai).
.mcp.json (key from the FORAL_INTEGRATION_KEY variable)
{
"mcpServers": {
"foral": {
"type": "http",
"url": "https://agents.foral.ai/mcp",
"headers": { "Authorization": "Bearer ${FORAL_INTEGRATION_KEY}" }
}
}
}List the tools (curl)
curl -s https://agents.foral.ai/mcp \
-H "Authorization: Bearer fik_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'What you approve
On the sign-in screen you choose the personal account and the workspaces that the connection may use. You also approve categories:
- Catalogue: see which agents you may use and how to call them.
- Typed skills: run an agent's bounded, typed operations.
- Conversational answers: ask an agent a question in plain language.
- Data domains: the Foral Data tools that your account already has.
Use it: catalogue first
Start with the catalogue. Discovery calls do not run a language model and do not use an answer quota. Then choose one agent and call it. Foral never picks an agent for you and never asks every agent at once.
workspace_ref is the public reference of a workspace, or personal for your own account. agent_ref is the public reference of an agent. Both come from the catalogue — Foral never shows internal IDs. If more than one account could pay for a call, the call is refused until you pass workspace_ref.
tools/list shows a tool only when you could call it now. For example, foral_agent_ask is listed only if you have a subscription with conversational answers.
Your access
curl -s https://agents.foral.ai/mcp \
-H "Authorization: Bearer fik_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"foral_access_get","arguments":{}}}'Ask an agent
curl -s https://agents.foral.ai/mcp \
-H "Authorization: Bearer fik_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"foral_agent_ask","arguments":{
"agent_ref": "<agent_ref from foral_agents_list>",
"workspace_ref": "<workspace_ref from foral_access_get>",
"question": "<your question>",
"idempotency_key": "ask-0001"}}}'| Tool | What it does |
|---|---|
foral_access_get | Your accounts and workspaces (workspace_ref and name), the categories you approved and the channels. |
foral_agents_list | The agents you may use. Optional: workspace_ref, cursor, limit (1 to 50, default 20). |
foral_agent_describe | One agent (agent_ref): purpose, operations, skill schemas, its own MCP and A2A addresses, and limits. |
foral_agent_skill | Runs one typed skill: agent_ref, skill (a name from foral_agent_describe), arguments. |
foral_agent_ask | Asks an agent a question: agent_ref, question, and optional workspace_ref, language, conversation_id, idempotency_key. |
data_… | The Foral Data tools, with the same data rights and quota as the Data API connection. Listed only if your account has Data API access. |
Results, refusals and retries
Each result carries a status in _meta.resultStatus. A refusal is never an empty success: when you may not do something, the result has isError: true and a code in structuredContent.code. An agent that does not exist and an agent you may not use give the same answer, unknown_target.
Answers keep the agent's name and published version, with the citations and the freshness it reports.
For foral_agent_ask, send an idempotency_key that you create. If a call times out, repeat it with the same key and the same question: Foral does not run the same request twice. Use a new key for a new question. The key is tied to your connection, the account, the agent and the request.
| Status | What it means |
|---|---|
success | The result is complete. |
partial | Part of the result. The message says what is missing. |
empty | The agent looked and found nothing. This is a real, empty result. |
unsupported | The agent or the data do not cover this request. |
permission_denied | Your consent, subscription or role does not allow this call. |
unavailable | A service could not answer now. Retry later. |
deferred | The work did not run now, for example because of a quota or a spend limit. Retry later. |
error | An unexpected failure. |
New subscriptions and the tool list
This server does not push changes: tools/list reports listChanged: false. After you buy or cancel a subscription, refresh the tool list in your client, or reconnect.
The catalogue tools stay the same, so a new agent shows up in foral_agents_list at once. A tool that you no longer have rights for is refused at call time, even if your client still shows it.
To move from the Data API connection to the main connection, connect again with the new address and approve it. Foral does not widen the old keys.
2. Narrow connection: one company agent
Each company agent published on the MCP channel has its own server: https://agents.foral.ai/<slug>/mcp. <slug> is the deployment slug shown in the company studio.
Authenticate with an agent credential created by a company admin in the studio (Deploy step, MCP channel). The tools are the ones the agent enables — its knowledge, service area and, when enabled, procurement reads. The deployment must be live.
This is the narrow connection: one deployment, one credential, only that agent's tools. Existing addresses and credentials stay valid. Use it for an integration that must reach a single agent. To reach every agent you may use with one sign-in, see section 1.
To publish your own company agent, see Foral Agents.
3. Data API connection (Foral Data MCP)
The Foral Data MCP server exposes the Data API as MCP tools: public procurement (Portal BASE), municipal signals, municipalities, your alerts and the indicator catalogue. URL: https://data.foral.ai/mcp.
It is for Premium accounts. Use the same sk_live_… key as the REST API — create it on the API keys page. The key's scopes and your plan decide which tools tools/list shows; a tool your key cannot call is simply not listed.
Same limits as the REST API: every HTTP request counts against your per-minute rate limit, and each tools/call counts as one request against your monthly quota. The handshake (initialize, tools/list, ping) does not use quota. Start with the me tool — it returns your plan, domains, scopes and limits.
This connection keeps its own keys, scopes and quota; the existing URL stays valid. An agent subscription does not include raw Data API access, and an integration key (fik_…) does not work on this server.
| Tool | Data domain |
|---|---|
me | — |
municipalities_search | indicators |
municipalities_get | indicators |
indicators_list | indicators |
indicators_series | indicators |
indicators_snapshot | indicators |
signals_list | signals |
signals_get | signals |
signal_cases_list | signals |
procurement_contracts | procurement |
procurement_aggregate | procurement |
procurement_entities | procurement |
procurement_entity_profile | procurement |
procurement_lookup_municipalities | procurement |
procurement_lookup_entities | procurement |
procurement_announcements | procurement |
procurement_amendments | procurement |
alert_rules | alerts |
alert_matches | alerts |
structuredContent (the same JSON the REST endpoint returns) and a text copy of it. A failed call (for example, monthly quota exhausted) comes back as a tool result with isError: true and the problem document of the REST API.4. Install the narrow and Data connections in your client
The examples use the Data MCP. For a company agent, use https://agents.foral.ai/<slug>/mcp and its credential instead. Replace sk_live_... with your key and keep it secret.
Claude Code
Then run claude mcp list — the server shows as connected.
Terminal
claude mcp add --transport http foral https://data.foral.ai/mcp \
--header "Authorization: Bearer sk_live_..."Claude Desktop (through mcp-remote)
Add this block to claude_desktop_config.json (Settings → Developer → Edit config) and restart Claude Desktop. It needs Node.js. The key goes in env so the header survives argument splitting on Windows.
claude_desktop_config.json
{
"mcpServers": {
"foral": {
"command": "npx",
"args": [
"-y", "mcp-remote", "https://data.foral.ai/mcp",
"--header", "Authorization:${AUTH_HEADER}",
"--transport", "http-only"
],
"env": { "AUTH_HEADER": "Bearer sk_live_..." }
}
}
}claude.ai, Claude Desktop connectors and ChatGPT
These clients connect with OAuth: you sign in to Foral and approve access — no key to paste.
- claude.ai and Claude Desktop: Customize → Connectors → Add → Add custom connector. Enter a name and the server URL, click Add (Claude detects OAuth and registers itself), then Connect. Foral opens: sign in and click Allow access.
- ChatGPT: Plugins → Add → Add custom MCP server. Enter a name and the server URL, keep Authentication on OAuth (ChatGPT registers itself), accept the risk notice and click Create as a plugin, then Continue. Foral opens: sign in and click Allow access.
- You can see and disconnect the apps you connected at any time in Connected apps.
Cursor and Windsurf
Cursor: add the block to ~/.cursor/mcp.json (or .cursor/mcp.json in a project). Windsurf: same block in ~/.codeium/windsurf/mcp_config.json, with serverUrl in place of url.
mcp.json
{
"mcpServers": {
"foral": {
"url": "https://data.foral.ai/mcp",
"headers": { "Authorization": "Bearer sk_live_..." }
}
}
}Python (MCP SDK 1.x)
Minimal example with the official MCP Python SDK, version 1.x (tested with 1.30). The 2.x SDK changed this client API.
client.py
# pip install "mcp>=1.30,<2" httpx
import asyncio
import httpx
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
URL = "https://data.foral.ai/mcp"
KEY = "sk_live_..."
async def main() -> None:
headers = {"Authorization": f"Bearer {KEY}"}
async with httpx.AsyncClient(headers=headers, timeout=30) as http:
async with streamable_http_client(URL, http_client=http) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([t.name for t in tools.tools])
result = await session.call_tool("municipalities_search", {"q": "Faro", "limit": 5})
print(result.structuredContent)
asyncio.run(main())Raw JSON-RPC (curl)
The servers speak Streamable HTTP with JSON responses: one JSON-RPC message per POST. There is no session to open — list the tools and call one.
List the tools
curl -s https://data.foral.ai/mcp \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'Call a tool
curl -s https://data.foral.ai/mcp \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"municipalities_search","arguments":{"q":"Faro","limit":5}}}'5. Limits
A 429 carries Retry-After (seconds). Wait that long before you retry.
| Server | Limit |
|---|---|
| Main Foral connection (Beta) | Discovery calls (initialize, tools/list, the catalogue tools) have a rate limit for each connection. A call that reaches an agent also counts against that agent's limits and the quota of the paying account. data_… tools use the quota of the Data API. |
| Foral Data MCP | Your plan's per-minute rate limit (every HTTP request) and monthly quota (one request per tools/call), shared with the REST API. |
| Company agent MCP | 60 requests/minute per credential, 200/minute per deployment (defaults). Connecting takes about 3 requests. |
6. Troubleshooting
| Answer | What it means |
|---|---|
401 (main connection) | Missing, expired or revoked sign-in or key. Sign in again, or send Authorization: Bearer fik_…. The WWW-Authenticate header points to the OAuth metadata of the server. |
unknown_target (main connection) | The agent_ref does not exist, or you may not use that agent. Foral gives the same answer for both. Call foral_agents_list. |
permission_denied (main connection) | Your consent, subscription, role or key channels do not allow this call. A tool missing from tools/list has the same cause. |
| A new agent is missing | Call foral_agents_list again. If a typed tool is missing, refresh the tool list or reconnect (listChanged is false). |
401 | Missing, wrong, expired or revoked key. Send Authorization: Bearer sk_live_…. |
403 | The request came from a browser page on another site (Origin header). Call the server from a desktop client, an IDE or your backend. On the Data MCP, a 403 can also mean your plan does not include Data API access (api-access-required, upgrade to Premium) or the key is restricted to a beta cohort (beta-access-required). |
404 (company agent) | Wrong <slug>, the deployment is not live, or the credential belongs to another deployment or lacks the MCP channel. |
405 | GET is not served: these servers are POST only. MCP clients handle this on their own. |
400 | Unsupported Mcp-Protocol-Version. Use 2025-06-18 or 2025-11-25. |
429 | Rate limit. Wait Retry-After seconds. |
quota-exceeded / 402 | Monthly quota exhausted. Wait for the reset or upgrade the plan. |
| A tool is missing | Your key lacks the scope or your plan lacks the domain. Call me to see both. |
503 | Temporary. Retry with backoff. |