Connecting Claude and Other MCP Clients
flAPI serves MCP over HTTP at POST http://<host>:<port>/mcp/jsonrpc, on the same port as the REST API. Any client that speaks MCP's HTTP transport connects directly; a client that can only start local (stdio) processes needs a bridge.
If you have not yet added an mcp-tool: block to an endpoint, start with the MCP Overview.
Which Client, Which Setup
| Client | How to connect | Auth | Protocol era | Tested |
|---|---|---|---|---|
| Claude Code | claude mcp add --transport http (below) | --header "Authorization: ..." | legacy (initialize) | yes: Status: ✔ Connected |
Python MCP SDK (mcp 2.3) | streamable_http_client (below) | headers on the HTTP client | legacy, 2025-11-25 | yes |
| Claude Desktop | the mcp-remote bridge (below) | --header argument to mcp-remote | legacy | the bridge was tested against flAPI; Claude Desktop itself was not |
| Cursor, VS Code | their HTTP MCP server config (URL plus headers) | Authorization header | depends on the client | no |
Every client authenticates on every request: flAPI checks credentials per request, not per session. The credentials are those of mcp.auth, which is separate from REST auth:.
Claude Code
The flAPI Claude Code plugin registers the MCP server for you and adds ten flAPI skills, seven slash commands and a hook that validates and hot-reloads your edits.
Claude Code speaks HTTP MCP natively. No bridge is needed:
# No mcp.auth
claude mcp add --transport http flapi http://localhost:8080/mcp/jsonrpc
# mcp.auth type: basic
claude mcp add --transport http flapi http://localhost:8080/mcp/jsonrpc \
--header "Authorization: Basic $(printf 'analyst:s3cret' | base64)"
# mcp.auth type: bearer
claude mcp add --transport http flapi http://localhost:8080/mcp/jsonrpc \
--header "Authorization: Bearer $FLAPI_MCP_TOKEN"
claude mcp get flapi # Status: ✔ Connected
--scope project writes the entry to .mcp.json, so the team shares it. Keep tokens out of that file.
If the server runs with --config-service, Claude Code also sees the flapi_* config tools and can create, update and reload endpoints during a coding session. Each of those calls needs the config-service token in an X-Config-Token header.
Python MCP SDK
import asyncio, base64
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
from mcp.shared._httpx_utils import create_mcp_http_client
URL = "http://localhost:8080/mcp/jsonrpc"
HEADERS = {} # with mcp.auth: {"Authorization": "Basic " + base64.b64encode(b"analyst:s3cret").decode()}
async def main():
async with create_mcp_http_client(headers=HEADERS) as http, \
streamable_http_client(URL, http_client=http) as (read, write, *_), \
ClientSession(read, write) as session:
await session.initialize()
print([t.name for t in (await session.list_tools()).tools])
result = await session.call_tool("find_customers", {"id": 3})
print(result.is_error, result.structured_content)
asyncio.run(main())
Run it with uvx --with mcp python client.py.
Claude Desktop and Other stdio-only Clients
Claude Desktop's mcpServers config starts each server as a local stdio process. To reach flAPI over HTTP it needs a bridge such as mcp-remote.
| OS | Config file |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
{
"mcpServers": {
"flapi": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:8080/mcp/jsonrpc",
"--header", "Authorization: Basic YW5hbHlzdDpzM2NyZXQ="]
}
}
}
Leave out the two --header arguments for a server without mcp.auth. Quit Claude Desktop fully and reopen it; your tools appear in the tools indicator.
"command": "curl"Claude Desktop expects a long-lived stdio MCP process, not a one-shot HTTP request. Use a stdio-to-HTTP bridge such as mcp-remote.
In production, put TLS in front of flAPI: Basic credentials and tokens travel with every request.
Direct API Use (Anthropic SDK)
When you call Claude through the Anthropic API, you can expose flAPI tools through tool use without an MCP client:
- Call flAPI's
tools/listonce and translate each tool (the typedinputSchemamaps directly to Anthropic'sinput_schema). - When Claude returns a
tool_useblock, calltools/callwithnameandarguments. - Return the result's
contentto Claude as atool_result.
import requests
import anthropic
FLAPI = "http://localhost:8080/mcp/jsonrpc"
HEADERS = {} # with mcp.auth: {"Authorization": "Bearer ..."} on every request
client = anthropic.Anthropic()
def jsonrpc(method, params=None, _id=1):
r = requests.post(FLAPI, headers=HEADERS, json={
"jsonrpc": "2.0", "id": _id, "method": method, "params": params or {},
})
return r.json()["result"]
mcp_tools = jsonrpc("tools/list")["tools"]
anthropic_tools = [
{"name": t["name"], "description": t["description"], "input_schema": t["inputSchema"]}
for t in mcp_tools
]
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
tools=anthropic_tools,
messages=[{"role": "user", "content": "Which BUILDING customers have the highest balance?"}],
)
for block in response.content:
if block.type == "tool_use":
result = jsonrpc("tools/call", {"name": block.name, "arguments": block.input})
# result["content"] is ready to send back as a tool_result
No initialize is needed for this pattern: flAPI keeps no state that a call depends on.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| No tools appear | The client cannot reach flAPI | curl http://localhost:8080/mcp/health and check tools_count |
| A tool you just added is missing | flAPI reads sqls/ at startup | Restart the server, or flapii endpoints reload --file sqls/<file>.yaml against a server with --config-service; then have the client list tools again (flAPI sends no list_changed) |
Every call fails with -32000, HTTP 401 | mcp.auth is on and no or wrong credentials were sent | Add the Authorization header to the client config |
-32000, HTTP 403 Permission denied | The caller holds none of the tool's allowed-roles, or the tool has no allowed-roles | Give the tool allowed-roles, or the user the role |
-32001 on a flapi_* tool | Missing or wrong config-service token | Send X-Config-Token: $FLAPI_CONFIG_SERVICE_TOKEN |
-32601 Method not found | Typo, or a method of the other protocol era | See the method table |
isError result with Unknown parameter | An argument the tool does not declare | Fix the argument name; inputs go under arguments |
More Information
- MCP Overview: tools, typed schemas, large results, protection
- MCP Protocol Reference: every JSON-RPC method, error code and header
- MCP Config Tools: admin tools for managing flAPI from Claude
- Claude Code Plugin: skills, commands and the reload hook
- Authentication: users, password hashes and JWTs
Need help wiring Claude into your data stack? Contact our team.