On this page
Connect an MCP client¶
Connect and choose the grant¶
Copy the connection URL from Access and keys into your MCP client.
The local quickstart uses http://localhost:13000/mcp. Agents can
list accessible Spaces, search their documents and open source passages.
OAuth. Sign in in the browser, choose the Spaces and grants, and approve the request. Use read access for retrieval. The client sends the access token as
Authorization: Bearer …. Review and revoke authorizations in Access and keys.API key. Create a For an agent (MCP) key, select at least one Space, set an expiry and save the full key in the client’s secret configuration. The client sends it as
X-API-Key.
Use one credential per request. To check a static key, set
CONTEXTBASE_BASE_URL to your installation and
CONTEXTBASE_API_KEY to the MCP key. Call:
curl --fail-with-body "$CONTEXTBASE_BASE_URL/mcp" \
-H "X-API-Key: $CONTEXTBASE_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Look for the tools in result.tools.
Search and open evidence¶
Call
list_knowledge_basesfor IDs, names and grants.Call
search_knowledge_basewithqueryand optionaltop_k. Supply a name or ID asknowledge_baseif the advertised schema requires it. Read the excerpts in rank order.Pass the canonical
chunk_idtofetch_sourcefor the full passage. Keep the excerpt if an attached index has no canonical chunk.For a written answer and sources, call
answer_from_knowledge_base. It needs a generator and can use model quota.
Implement a host¶
Send JSON-RPC messages by POST to /mcp. Call initialize
and send the negotiated revision in MCP-Protocol-Version.
Authenticate each call. Each request gets one complete response.
The server issues no session ID.
For OAuth discovery, use /.well-known/oauth-authorization-server
and /.well-known/oauth-protected-resource. The authorization code
flow with PKCE uses /oauth/authorize and /oauth/token.
Fetch a fresh tool list after a grant changes. Removing Space access
can revoke the connection and require approval again.