mcpstore Documentation

repository·main·Indexed 19 days ago

https://github.com/ip2a/mcpstore

A management package for Model Context Protocol (MCP) services featuring a Rust-first architecture. It allows developers to maintain, group, and expose MCP services to AI frameworks such as LangChain, AutoGen, LlamaIndex, LangGraph, and CrewAI. The project provides a Python SDK for programmatic management, a Rust CLI for standalone HTTP API and MCP Server capabilities, and support for distributed management using Redis as a shared cache backend.

Tokens
57K
Snippets
219
Records
273
Agent score
64%

What's inside mcpstore

  1. Overview of MCP Service Management tasks

    main

    MCPStore is primarily used to manage Model Context Protocol (MCP) services. Common management tasks include:

    • Adding a new MCP service.
    • Viewing currently active services and their configurations.
    • Checking the health status of services.
    • Inspecting the specific Tools, Prompts, and Resources provided by a service.
    • Lifecycle management: Updating, restarting, or deleting services.
  2. What is MCPStore

    main

    MCPStore is a unified management tool for Model Context Protocol (MCP) services.

    Key distinction: MCPStore manages the MCP services themselves—including their availability and capabilities—rather than managing the Agents that use them.

    Core Capabilities:

    • Configuration Management: Save and modify MCP service configurations.
    • Lifecycle Management: Start, stop, restart, and delete services.
    • Health Monitoring: View service status and perform health checks.
    • Service Discovery: Discover the Tool, Prompt, and Resource capabilities provided by services.
    • Client Integration: Provide access for local programs, coding assistants, or other MCP clients.
    • Deployment Flexibility: Manage local instances or connect to remote instances.
  3. Overview of MCPStore usage patterns

    main

    MCPStore is a management system for Model Context Protocol (MCP) services. Depending on your requirements, you can use it in the following ways:

    • Manage MCP Services: Add, configure, monitor status, perform health checks, update, and delete MCP services.
    • Local Usage: Manage MCP services running on your local machine using a Command Line Interface (CLI), Terminal User Interface (TUI), or a desktop application.
    • Code Integration: Integrate MCPStore capabilities directly into your own Rust or Python projects.
    • Remote Usage: Connect to and use an MCPStore instance running on a remote server.
  4. Locate the mcpstore Python source and Rust bindings

    main
    The official Python source code for mcpstore is located in the python/src/mcpstore directory. When using the package, the Rust bindings are integrated into the package under the _rust* naming convention (e.g., python/src/mcpstore/_rust*).
  5. Group MCP services for specific Agents

    main

    Use store.for_agent(agent_id) to create isolated subsets of MCP services for different agents. This prevents context window bloat by ensuring an agent only sees the tools relevant to its specific task.

    store.for_agent(agent_id) mirrors most of the interface found in store.for_store(), but operates on a logical subset of the total services.

    Example: Isolating Services

    from mcpstore import MCPStore
    store = MCPStore.setup_store()
    
    # Agent 1 gets wiki access
    agent_id1 = "agent1"
    store.for_agent(agent_id1).add_service({"name": "mcpstore_wiki", "url": "https://example.com/mcp"})
    
    # Agent 2 gets gitodo access via command line
    agent_id2 = "agent2"
    store.for_agent(agent_id2).add_service({"name": "gitodo", "command": "uvx", "args": ["gitodo"]})
    
    # Retrieve tools for specific agents
    agent1_tools = store.for_agent(agent_id1).list_tools()
    agent2_tools = store.for_agent(agent_id2).list_tools()
    from mcpstore import MCPStore
    store = MCPStore.setup_store()
    
    agent_id1 = "agent1"
    store.for_agent(agent_id1).add_service({"name": "mcpstore_wiki", "url": "https://example.com/mcp"})
    
    agent_id2 = "agent2"
    store.for_agent(agent_id2).add_service({"name": "gitodo", "command": "uvx", "args": ["gitodo"]})
    
    agent1_tools = store.for_agent(agent_id1).list_tools()
    agent2_tools = store.for_agent(agent_id2).list_tools()
  6. Understand the MCPStore relationship model

    main

    MCPStore acts as a central hub (an instance) that manages multiple MCP services. The architecture follows this flow:

    1. Users interact with an Entry Point (CLI, TUI, Desktop App, Web, Rust, or Python).
    2. The Entry Point connects to an MCPStore Instance.
    3. The MCPStore Instance manages and provides access to multiple MCP Services.
    4. MCP Clients (such as programming assistants or other MCP-compatible tools) connect to the MCPStore Instance to consume services.
  7. Understand MCPStore usage interfaces

    main

    MCPStore provides multiple interfaces to interact with the same core system. These are different entry points to the same product, not separate products. While the underlying concepts are shared, the specific methods of interaction vary by interface:

    • CLI (Command Line Interface)
    • TUI (Terminal User Interface)
    • Desktop App
    • Web Interface
    • Rust SDK/Integration
    • Python SDK/Integration
  8. Understand the core concepts of MCPStore

    main

    Before using MCPStore, you should understand three fundamental concepts:

    1. What MCPStore is: The core definition and purpose of the system.
    2. How MCP services are managed: The lifecycle and mechanisms for controlling MCP services.
    3. The relationship between Local, Remote, and Clients: How local instances, remote instances, and MCP clients (like programming assistants) interact within the ecosystem.
  9. Choose between Local and Remote MCPStore instances

    main

    Depending on your use case, you can deploy MCPStore in two modes:

    • Local Instance: Runs on your local machine. This is ideal for personal use and local development workflows.
    • Remote Instance: Runs on a server. Local entry points or other devices connect to it, making it suitable for centralized management of MCP services across multiple environments.
  10. Understand the API response format

    main

    All routes in this demo return a unified JSON envelope to ensure consistent client handling:

    {
      "ok": true,
      "data": <payload>,
      "error": null,
      "message": "ok"
    }

    When a request fails, ok will be false, and the error field will contain the reason for failure, accompanied by an appropriate HTTP status code.

    {
      "ok": true,
      "data": <payload>,
      "error": null,
      "message": "ok"
    }
  11. Use the 'only_db' mode for resource-constrained environments

    main

    In a distributed setup, you can run a store instance in only_db=True mode. This instance does not manage or maintain the services itself; instead, it acts as a client that interacts with the shared database. All operations on MCP services in this mode will notify the primary environment (the one managing the actual processes) via events.

    from mcpstore import MCPStore
    from mcpstore.config import RedisConfig
    
    redis_config = RedisConfig(
      host="127.0.0.1",
      port=6379,
      password=None,
      namespace="demo_namespace"
    )
    
    # Configure as a client-only instance
    store = MCPStore.setup_store(cache=redis_config, only_db=True)
    
    # Operations here will interact with the shared Redis state
    store.for_store().list_services()
  12. How agent grouping works in mcpstore

    main

    To prevent context overflow and isolate tools, you can group MCP services by agent_id. Using store.for_agent(agent_id) creates a logical subset of the global store. This subset mirrors most of the for_store() interface but only operates on services assigned to that specific agent.

    agent_id1 = "agent1"
    # This service is only visible to agent1
    store.for_agent(agent_id1).add_service({"name": "mcpstore_wiki", "url": "https://example.com/mcp"})
    
    agent_id2 = "agent2"
    # This service is only visible to agent2
    store.for_agent(agent_id2).add_service({"name": "gitodo", "command": "uvx", "args": ["gitodo"]})
    
    # Retrieve tools for a specific agent
    agent1_tools = store.for_agent(agent_id1).list_tools()