Skip to content

feat. implement simple mcp - #405

Merged
SarahScargall merged 1 commit into
MemMachine:mainfrom
jealous:feature/sepMcp
Nov 3, 2025
Merged

SarahScargall merged 1 commit into
MemMachine:mainfrom
jealous:feature/sepMcp

Conversation

@jealous

@jealous jealous commented Oct 30, 2025 •

Copy link
Copy Markdown
Contributor

Purpose of the change

Implement a simpler MCP.

Description

Replaces the complex MCP implementation with a simpler version.

The new MCP contains only two methods:

  • add memory — requires two parameters:
    • user_id: the user to whom the memory belongs. It can be overridden
      by the MM_USER_ID environment variable or the user-id field in
      the HTTP request header.
    • content: the content to memorize.
  • query memory — requires three parameters:
    • user_id: the user from whom to retrieve memory.
    • limit: maximum number of memories to retrieve.
    • query: the related topic to query.

Each method maintains a minimal set of parameters, and the descriptions
are tuned to help the LLM better understand the tools.

Adds two tools to start the MCP:

  • memmachine-mcp-stdio: starts the MCP server in stdio mode.
  • memmachine-mcp-http: starts the MCP as an HTTP server without REST
    API.

Changes in the main server:

  • memmachine-server retains the old behavior—it starts the REST API
    server with MCP available at /mcp.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g., code style improvements, linting)
  • Documentation update
  • Project Maintenance (updates to build scripts, CI, etc., that do not affect the main project)
  • Security (improves security without changing functionality)

How Has This Been Tested?

Unittest is added for the server layer. Integration test done with the Claude App.

  • Unit Test
  • Integration Test
  • End-to-end Test
  • Test Script (please provide)
  • Manual verification (list step-by-step instructions)

Test Results:

Checklist

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project (See STYLE_GUIDE.md)
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • Confirmed all checks passed
  • Contributor has signed the commit(s)
  • Reviewed the code
  • Run, Tested, and Verified the change(s) work as expected

@jealous
jealous marked this pull request as draft October 30, 2025 06:49
@jealous
jealous force-pushed the feature/sepMcp branch 3 times, most recently from 4a405e4 to ebc7fba Compare October 31, 2025 22:33
@jealous
jealous marked this pull request as ready for review October 31, 2025 22:35
@jealous
jealous force-pushed the feature/sepMcp branch 4 times, most recently from 457b6c3 to 418503e Compare October 31, 2025 22:41
@jealous jealous changed the title feat. implement simple stdio mcp feat. implement simple mcp Oct 31, 2025
@jealous
jealous requested a review from a team October 31, 2025 22:56
@jealous jealous self-assigned this Oct 31, 2025
@jealous
jealous requested a review from Copilot October 31, 2025 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a simplified MCP (Model Content Protocol) server for MemMachine, replacing complex MCP tools with two streamlined methods: add_memory and search_memory. The new implementation focuses on better LLM integration with clearer descriptions and minimal parameter sets.

  • Simplified MCP interface with two core tools optimized for LLM interaction
  • Added two new command-line entry points for standalone MCP operation
  • Implemented user ID context management with environment variable override support
  • Restructured application lifespan management to support both standalone MCP and integrated HTTP modes

Reviewed Changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/memmachine/server/test_mcp_stdio.py Comprehensive test suite for the new MCP implementation with parameter validation and tool functionality tests
src/memmachine/server/mcp_stdio.py New standalone MCP server in stdio mode for direct protocol communication
src/memmachine/server/mcp_http.py New standalone MCP server in HTTP mode with command-line argument parsing
src/memmachine/server/app.py Major refactoring of MCP tools, user context management, and application structure
src/memmachine/common/embedder/embedder_builder.py Minor error message improvement for sentence-transformer configuration
pyproject.toml Added new command-line entry points for MCP servers
docs/examples/mcp.mdx Updated documentation with new MCP usage examples and Claude Desktop integration guide
Comments suppressed due to low confidence (1)

src/memmachine/server/app.py:1

  • The deprecated=True parameter was removed from the session field definition, but there's no indication in the PR description or commit that this deprecation warning should be removed. This could affect users who rely on this warning to migrate away from the deprecated field.
"""FastAPI application for the MemMachine memory system.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/memmachine/server/app.py Outdated
Comment thread src/memmachine/server/app.py

@o-love o-love left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

A few nits and a suggestion.

Comment thread src/memmachine/server/app.py
Comment thread docs/examples/mcp.mdx
Comment thread docs/examples/mcp.mdx Outdated
@jealous
jealous force-pushed the feature/sepMcp branch 3 times, most recently from 2e4cf93 to 863d46e Compare November 1, 2025 01:09
Implements a simplified MCP (Model Content Protocol) server for
MemMachine, replacing complex MCP tools with two streamlined methods:
`add_memory` and `search_memory`. The new implementation focuses on
better LLM integration with clearer descriptions and minimal parameter
sets.

- Simplify MCP interface with two core tools optimized for LLM
  interaction
- Add two new command-line entry points for standalone MCP operation
- Implement user ID context management with environment variable
  override support
- Restructure application lifespan management to support both standalone
  MCP and integrated HTTP modes
@sscargal
sscargal requested a review from a team November 3, 2025 18:34

@SarahScargall SarahScargall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Content is solid. I may edit it so the responses and code are in the same window at a future time, but this is very good for now.

@SarahScargall
SarahScargall merged commit 8ea1520 into MemMachine:main Nov 3, 2025
64 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants