popoto.integrations.mcp_server¶
popoto.integrations.mcp_server
¶
Stdio MCP server exposing the discretionary half of harness memory.
Four tools, one naming convention, frozen: memory_search,
memory_save, memory_feedback, memory_status. They end up in
users' harness configs, in blog posts, and in other projects' docs, so
renaming one later breaks installs silently. A test asserts these four
names literally.
These tools are not how recall and capture happen. MCP tools are
agent-elected: the model calls them when it decides to. Subconscious memory
means memory runs on every turn whether or not the model asks, which is
what the hook path in :mod:popoto.integrations.hooks does. This server is
for the discretionary half -- searching mid-task, saving something
explicitly, and correcting a memory that turned out wrong -- plus clients
that have no hook surface at all.
The tool logic lives in :func:tool_definitions and :func:dispatch,
which are plain Python and import nothing from the MCP SDK. Only
:func:build_server and :func:serve touch mcp, and they import it
lazily, so popoto.integrations stays usable on a bare
pip install popoto.
TOOL_NAMES = ('memory_search', 'memory_save', 'memory_feedback', 'memory_status')
module-attribute
¶
The frozen public tool names. Do not add a second convention: Mem0
publishes add_memories/search_memory in one product and
add_memory/search_memories in another, and pays for it in user
confusion.
SERVER_NAME = 'popoto-memory'
module-attribute
¶
Server name as it appears in harness MCP configuration.
tool_definitions()
¶
Describe the four tools as plain JSON-schema dicts.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
One dict per tool with |
List[Dict[str, Any]]
|
|
Source code in src/popoto/integrations/mcp_server.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
dispatch(name, arguments=None, service=None)
¶
Execute one tool call and return an MCP-shaped result dict.
Errors become readable messages with is_error set, never a
traceback rendered as tool output: the model reads this text and a
traceback teaches it nothing actionable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
One of :data: |
required |
arguments
|
Optional[Dict[str, Any]]
|
The tool's arguments. |
None
|
service
|
Any
|
Optional :class: |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
|
Source code in src/popoto/integrations/mcp_server.py
build_server()
¶
Construct the MCP :class:~mcp.server.Server for this integration.
Imports the MCP SDK, so it raises :class:ImportError without
pip install popoto[mcp]. The SDK has changed its registration API
across major versions, so both the callback constructor (2.x) and the
decorator style (1.x) are supported here; the tool behavior itself is
shared and version-independent.
Returns:
| Type | Description |
|---|---|
Any
|
A configured MCP |
Source code in src/popoto/integrations/mcp_server.py
serve()
¶
Run the stdio MCP server until the client disconnects.
Blocks. This is what popoto-memory mcp calls.