Sophia MCP Server
RESTHeart CloudSophia MCP Server
Connect any MCP-compatible AI client to your RESTHeart knowledge base in minutes.
Endpoint: https://sophia-api.restheart.com/mcp — no authentication required for public knowledge bases.
Selecting a Context
Sophia supports multiple Contexts, each representing a distinct knowledge base with its own prompt template, tag filters, and RAG options. Select the desired context via the X-Sophia-Context header.
| Context | Knowledge base |
|---|---|
|
RESTHeart documentation, plugin API, configuration guides |
|
RESTHeart Cloud managed service docs |
|
This is a demo about a fictional product: the BrewMaster Pro 3000 coffee maker (requires authentication) |
Filtering by Tag
Within a context, documents are organized by tags. The optional X-Sophia-Tags header narrows retrieval to documents that carry all of the specified tags (comma-separated). Use sophia_list_tags to discover which tags are available in your context.
| Header value | Effect |
|---|---|
(omitted) |
All documents in the context are searched |
|
Only documents tagged |
|
Only documents tagged |
|
Only documents tagged with both |
RESTHeart
{
"mcpServers": {
"sophia-restheart": {
"command": "npx",
"args": ["mcp-remote", "https://sophia-api.restheart.com/mcp", "--header", "X-Sophia-Context: restheart"]
}
}
}
The restheart context covers both RESTHeart and RESTHeart Cloud documentation. To restrict retrieval to RESTHeart-only documents, add the X-Sophia-Tags header (see [_filtering_by_tag]):
{
"mcpServers": {
"sophia-restheart": {
"command": "npx",
"args": ["mcp-remote", "https://sophia-api.restheart.com/mcp",
"--header", "X-Sophia-Context: restheart",
"--header", "X-Sophia-Tags: restheart"]
}
}
}
RESTHeart Cloud
{
"mcpServers": {
"sophia-cloud": {
"command": "npx",
"args": ["mcp-remote", "https://sophia-api.restheart.com/mcp", "--header", "X-Sophia-Context: cloud"]
}
}
}
The snippets above use mcp-remote, a small Node.js bridge that exposes the HTTP endpoint as a local stdio process — the format most clients expect. It requires Node.js ≥ 18 and is downloaded automatically by npx on first run.
Clients that natively support HTTP/SSE transport (Cursor, VS Code, newer Claude Desktop) can connect directly without mcp-remote, using a simpler type: sse config — see below.
Client-specific notes
Claude Desktop — add the snippet above under mcpServers in claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows), then restart.
Cursor / VS Code — support HTTP natively; use "type": "sse" with a "headers" map instead of command/args:
{
"sophia-restheart": {
"type": "sse",
"url": "https://sophia-api.restheart.com/mcp",
"headers": { "X-Sophia-Context": "restheart" }
}
}
Claude Code — add to your project’s .mcp.json or global MCP config.
Available Tools
| Tool | Description |
|---|---|
|
Semantic search over the knowledge base. Returns relevant text segments with |
|
Retrieves the full content of a document by filename (all chunks merged in order). Use after |
|
Lists all accessible documents with tags and chunk count. Accepts an optional |
|
Lists the tags available in the knowledge base, filtered by the active context and credentials. |
|
Lists immediate subdirectories under a given path prefix, like |
|
Builds a fully interpolated system prompt with RAG context injected, ready to send to any LLM as a |
|
Returns the complete Sophia REST API reference. Requires authentication — reserved for service administrators. |
Recommended Tool-Chaining Workflow
To maximise the context available to an AI agent:
-
sophia_search— find relevant chunks; note theSource:filename andPath:directory in each result. -
sophia_get_file— retrieve the full file fromSource:(not just the matched chunk). -
sophia_list_fileswithpath=<Path:>— discover all related files in the same directory. -
sophia_get_file— retrieve any relevant sibling files.
To explore the knowledge base structure before searching:
sophia_list_paths → top-level directories
sophia_list_paths(path=X) → subdirectories under X
sophia_list_files(path=X) → files in directory X
sophia_list_tags → available tags