Model Context Protocol (MCP)
Relevant source files
The following files were used as context for generating this wiki page:
The Model Context Protocol (MCP) in oboete enables coding agents to search and retrieve stored memory from within a session. It provides a standardized interface for agents like Claude, Cursor, and Codex to access observations, session summaries, and developer prompts.
Sources: src/mcp.rs:1-6, src/setup.rs:12-14
Architecture and Components
The MCP implementation uses a stdio-based server architecture. The Oboete struct maintains the server state, including the home directory for the database and the current working directory (CWD) from which the agent launched the server.
Sources: src/mcp.rs:16-22
Key Data Structures
- Oboete Struct: Holds
home(PathBuf),cwd(PathBuf), and atool_router. - SearchArgs: Defines parameters for memory searches, including the query string, repository scope, and hit limits.
- GetArgs: Specifies a document ID to retrieve full text.
- TimelineArgs: Defines parameters for viewing session history.
Sources: src/mcp.rs:24-63
Logical Flow
The following diagram illustrates how the MCP server initializes and handles requests from an agent.
The server runs a rekey operation on startup to ensure repositories are identified by their origins if they have changed since the last session.
Sources: src/mcp.rs:215-227, src/mcp.rs:241-250
MCP Tools
The server exposes three primary tools to the agent. Every tool response passes through an egress gate (redact::outbound) to ensure secrets are masked before reaching the model.
Sources: src/mcp.rs:69-73
search
The search tool finds observations, summaries, and prompts. It uses trigram matching and semantic search (if enabled).
| Parameter | Type | Description |
|---|---|---|
query | String | Words or sentences to match. |
all | Option<bool> | Search all repositories if true. |
repo | Option<String> | Path or key of a specific repository. |
limit | Option<usize> | Max hits (default 10, max 100). |
Sources: src/mcp.rs:26-44, src/mcp.rs:125-155
get
The get tool retrieves the full text of a specific document identified by a search hit.
| Parameter | Type | Description |
|---|---|---|
id | String | Document ID (e.g., o12, s5, p7). |
Sources: src/mcp.rs:46-51, src/mcp.rs:157-181
timeline
The timeline tool provides a history of coding sessions in a repository, sorted newest first.
| Parameter | Type | Description |
|---|---|---|
all | Option<bool> | Show sessions from all repositories. |
repo | Option<String> | Filter by specific repository path or key. |
limit | Option<usize> | Max sessions (default 20, max 100). |
Sources: src/mcp.rs:53-63, src/mcp.rs:183-211
Agent Integration and Setup
The oboete setup command wires agents to the MCP server. Configuration is stored in agent-specific files, typically using the server name oboete.
Sources: src/setup.rs:1-14
Supported Agents
The system supports multiple agents with specific event hooks and configuration formats:
| Agent | Configuration File | Format |
|---|---|---|
| Claude | .claude.json / settings.json | JSON |
| Codex | config.toml | TOML |
| Grok | config.toml | TOML |
| Agy | mcp_config.json | JSON |
| Cursor | mcp.json | JSON |
Sources: src/setup.rs:16-17, src/setup.rs:218-356, src/setup.rs:651-687
Connection Sequence
The sequence below describes how an agent connects to and utilizes the MCP server.
Sources: src/mcp.rs:125-181, src/mcp.rs:227-236
Security and Redaction
The MCP server enforces security through the "egress gate." It prevents recursive memory loops and sensitive data leaks.
Recursive Loop Prevention
A window shows the tool call but not the output if it detects a read of stored memory. This applies to:
- oboete's own MCP tools.
- Commands running
oboete search,get, ortimeline. claude-memtools.
Sources: src/curate.rs:250-264
Secret Masking
The redact::outbound function is applied to all text before it is sent to the agent. This ensures that:
- User-defined rules in
config.tomlare honored. - Rules added after a document was stored are still applied.
- Base64 images and binary content are replaced with markers.
Sources: src/mcp.rs:69-73, src/capture.rs:364-378, src/curate.rs:223-233
Configuration Options
The MCP server behavior is influenced by config.toml settings located in the home directory.
| Option | Location | Default | Description |
|---|---|---|---|
language | [summary] | "Japanese" | Language for observations and summaries. |
max_output_tokens | [limits] | 4000 | Max response size for paid entries. |
daily_budget | [[providers]] | 300 | Daily call cap for OpenAI-compatible providers. |
Sources: src/config.rs:104-118, src/config.rs:188-193, src/config.rs:228-232
Summary
The oboete MCP implementation provides a robust, secure, and searchable memory interface for coding agents. By integrating directly via stdio and enforcing strict redaction at the egress point, it allows agents to leverage project history and developer preferences while maintaining data privacy and avoiding recursive context inflation.