Skip to main content

A composable, ready-to-use MCP toolkit for agents and rapid integration.

Project description

ไธญๆ–‡ | English

๐Ÿš€ McpStore - Add MCP Capabilities to Your Agent in Three Lines of Code

McpStore is a tool management library specifically designed to solve the problem of Agents wanting to use MCP (Model Context Protocol) capabilities while being overwhelmed by MCP management.

MCP is rapidly evolving, and we all want to add MCP capabilities to existing Agents, but introducing new tools to Agents typically requires writing a lot of repetitive "glue code", making the process cumbersome ๐Ÿ˜ค

Implement MCP Tools Ready-to-Use in Three Lines of Code โšก

No need to worry about mcp protocol and configuration details, just use intuitive classes and functions with an extremely simple user experience.

# Import MCPStore library
from mcpstore import MCPStore
# Step 1: Initialize a Store, which is the core entry point for managing all MCP services
store = MCPStore.setup_store()
# Step 2: Register an external MCP service, MCPStore will automatically handle connection and tool loading
store.for_store().add_service({"name":"mcpstore-wiki","url":"http://mcpstore.wiki/mcp"})
# Step 3: Get a tool list fully compatible with LangChain, ready for direct use with Agent
tools = store.for_store().for_langchain().list_tools()
# At this moment, your LangChain Agent has successfully integrated all tools provided by mcpstore-wiki

A Complete Runnable Example - Direct Integration of MCP Services with LangChain ๐Ÿ”ฅ

Below is a complete, directly runnable example showing how to seamlessly integrate tools obtained from McpStore into a standard langChain Agent.

from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from mcpstore import MCPStore
store = MCPStore.setup_store()
store.for_store().add_service({"name":"mcpstore-wiki","url":"http://mcpstore.wiki/mcp"})
tools = store.for_store().to_langchain_tools()
llm = ChatOpenAI(
    temperature=0, model="deepseek-chat",
    openai_api_key="sk-****",
    openai_api_base="https://api.deepseek.com"
)
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are an assistant, answer with emojis"),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
query = "How's the weather in Beijing?"
print(f"\n   ๐Ÿค”: {query}")
response = agent_executor.invoke({"input": query})
print(f"   ๐Ÿค– : {response['output']}")

Or if you don't want to use langchain and plan to design your own tool calls ๐Ÿ› ๏ธ

from mcpstore import MCPStore
store = MCPStore.setup_store()
store.for_store().add_service({"name":"mcpstore-wiki","url":"http://mcpstore.wiki/mcp"})
tools = store.for_store().list_tools()
print(store.for_store().use_tool(tools[0].name,{"query":'Beijing'}))

Quick Start

Installation

pip install mcpstore

Chaining Calls โ›“๏ธ

I really dislike complex and overly long function names. For intuitive code display, McpStore uses chaining. Specifically, store is a foundation. If you have different agents and want your different agents to be experts in different domains (using isolated different MCPs), you can try for_agent. Each agent is isolated, and you can determine your agent's identity through a custom agentid, ensuring it performs better within its scope.

  • store.for_store(): Enter global context, where managed services and tools are visible to all Agents.
  • store.for_agent("agent_id"): Create an isolated private context for an Agent with the specified ID. Each

Multi-Agent Isolation ๐Ÿ 

The following code demonstrates how to use context isolation to assign dedicated tool sets to Agents with different functions.

# Initialize Store
store = MCPStore.setup_store()

# Assign dedicated Wiki tools to "Knowledge Management Agent"
# This operation is performed in the "knowledge" agent's private context
agent_id1 = "my-knowledge-agent"
knowledge_agent_context = store.for_agent(agent_id1).add_service(
    {"name": "mcpstore-wiki", "url": "http://mcpstore.wiki/mcp"}
)

# Assign dedicated development tools to "Development Support Agent"
# This operation is performed in the "development" agent's private context
agent_id2 = "my-development-agent"
dev_agent_context = store.for_agent(agent_id2).add_service(
    {"name": "mcpstore-demo", "url": "http://mcpstore.wiki/mcp"}
)

# Each Agent's tool set is completely isolated without affecting each other
knowledge_tools = store.for_agent(agent_id1).list_tools()
dev_tools = store.for_agent(agent_id2).list_tools()

Intuitively, you can use almost all functions through store.for_store() and store.for_agent("agent_id") โœจ

McpStore's setup_store() ๐Ÿ”ง

๐Ÿ“‹ Overview

MCPStore.setup_store() is MCPStore's core initialization method, used to create and configure MCPStore instances. This method supports custom configuration file paths and debug mode, providing flexible configuration options for different environments and use cases.

๐Ÿ”ง Method Signature

@staticmethod
def setup_store(mcp_config_file: str = None, debug: bool = False) -> MCPStore

Parameter Description:

  • mcp_config_file: Custom mcp.json configuration file path (optional)
  • debug: Whether to enable debug logging mode (optional, default False)
  • Return Value: Fully initialized MCPStore instance

๐Ÿ“‹ Parameter Details

1. mcp_config_file Parameter

  • When not specified: Uses default path src/mcpstore/data/mcp.json
  • When specified: Uses the specified mcp.json configuration file to instantiate your store, supports mainstream client file formats, ready to use ๐ŸŽฏ

2. debug Parameter

Basic Description
  • Type: bool
  • Default Value: False
  • Function: Controls log output level and detail
Log Configuration Comparison
Mode debug=False (default) debug=True
Log Level ERROR DEBUG
Log Format %(levelname)s - %(message)s %(asctime)s - %(name)s - %(levelname)s - %(message)s
Display Content Only error messages All debug information

๐Ÿ“ Supported JSON Configuration Formats

Standard MCP Configuration Format

MCPStore uses standard MCP configuration format, supporting both URL-based and command-based service configurations:

{
  "mcpServers": {
    "mcpstore-wiki": {
      "url": "http://mcpstore.wiki/mcp"
    },
    "howtocook": {
      "command": "npx",
      "args": [
        "-y",
        "howtocook-mcp"
      ]
    }
  }
}

Scenario: Multi-tenant Configuration ๐Ÿข

# Tenant A configuration
tenant_a_store = MCPStore.setup_store(
    mcp_config_file="tenant_a_mcp.json",
    debug=False
)

# Tenant B configuration
tenant_b_store = MCPStore.setup_store(
    mcp_config_file="tenant_b_mcp.json",
    debug=False
)

# Provide isolated services for different tenants
tenant_a_tools = tenant_a_store.for_store().list_tools()
tenant_b_tools = tenant_b_store.for_store().list_tools()

Powerful Service Registration add_service ๐Ÿ’ช

The core of mcpstore is store. Simply initialize a store through setup_store(), and you can register any number of services supporting all MCP protocols on this store. No need to worry about the lifecycle and maintenance of individual mcp services, no need to worry about CRUD operations for mcp services - store will take full responsibility for the lifecycle maintenance of these services.

When you need to integrate these services into langchain Agent, calling store.for_store().to_langchain_tools() provides one-click conversion to a tool set fully compatible with langchain Tool structure, convenient for direct use or seamless integration with existing tools.

Or you can directly use the store.for_store().use_tool() method to customize your desired tool calls ๐ŸŽฏ.

Service Registration Methods

All services added through add_service have their configurations uniformly managed and can optionally be persisted to the mcp.json file registered during setup_store. Deduplication and updates are automatically handled by mcpstore โš™๏ธ.

Basic Syntax

store = MCPStore.setup_store()
store.for_store().add_service(config)

Supported Registration Methods

1. ๐Ÿ”„ Full Registration (No Parameters)

Register all services in the mcp.json configuration file.

store.for_store().add_service()

Without passing any parameters, add_service will automatically find and load the mcp.json file in the project root directory, which is compatible with mainstream formats.

Use Cases:

  • One-time registration of all pre-configured services during project initialization
  • Reload all service configurations

2. ๐ŸŒ URL-based Registration

Add remote MCP services through URL.

store.for_store().add_service({
    "name": "mcpstore-wiki",
    "url": "http://mcpstore.wiki/mcp",
    "transport": "streamable-http"
})

Fields:

  • name: Service name
  • url: Service URL
  • transport: Optional field, can automatically infer transport protocol (streamable-http, sse)

3. ๐Ÿ’ป Local Command Registration

Start local MCP service processes.

# Python service
store.for_store().add_service({
    "name": "local_assistant",
    "command": "python",
    "args": ["./assistant_server.py"],
    "env": {"DEBUG": "true", "API_KEY": "your_key"},
    "working_dir": "/path/to/service"
})

# Node.js service
store.for_store().add_service({
    "name": "node_service",
    "command": "node",
    "args": ["server.js", "--port", "8080"],
    "env": {"NODE_ENV": "production"}
})

# Executable file
store.for_store().add_service({
    "name": "binary_service",
    "command": "./mcp_server",
    "args": ["--config", "config.json"]
})

Required Fields:

  • name: Service name
  • command: Execution command

Optional Fields:

  • args: Command parameter list
  • env: Environment variable dictionary
  • working_dir: Working directory

4. ๐Ÿ“„ MCPConfig Dictionary Registration

Use standard MCP configuration format.

store.for_store().add_service({
  "mcpServers": {
    "mcpstore-wiki": {
      "url": "http://mcpstore.wiki/mcp"
    },
    "howtocook": {
      "command": "npx",
      "args": [
        "-y",
        "howtocook-mcp"
      ]
    }
  }
})

5. ๐Ÿ“ Service Name List Registration

Register specific services from existing configuration.

# Register specified services
store.for_store().add_service(['mcpstore-wiki', 'howtocook'])

# Register single service
store.for_store().add_service(['howtocook'])

Prerequisites: Services must be defined in the mcp.json configuration file ๐Ÿ“‹.


6. ๐Ÿ“ JSON File Registration

Read configuration from external JSON files.

# Read configuration from file
store.for_store().add_service(json_file="./demo_config.json")

# Specify both config and json_file (json_file takes priority)
store.for_store().add_service(
    config={"name": "backup"},
    json_file="./demo_config.json"  # This will be used โšก
)

JSON File Format Examples:

{
  "mcpServers": {
    "mcpstore-wiki": {
      "url": "http://mcpstore.wiki/mcp"
    },
    "howtocook": {
      "command": "npx",
      "args": [
        "-y",
        "howtocook-mcp"
      ]
    }
  }
}

And other formats supported by add_service ๐Ÿ“

{
    "name": "mcpstore-wiki",
    "url": "http://mcpstore.wiki/mcp"
}

RESTful API ๐ŸŒ

In addition to being used as a Python library, MCPStore also provides a complete RESTful API suite, allowing you to seamlessly integrate MCP tool management capabilities into any backend service or management platform.

One command to start a complete Web service:

pip install mcpstore
mcpstore run api

Get 38 API endpoints immediately after startup ๐Ÿš€

๐Ÿ“ก Complete API Ecosystem

Store Level API ๐Ÿช

# Service Management
POST /for_store/add_service          # Add service
GET  /for_store/list_services        # Get service list
POST /for_store/delete_service       # Delete service
POST /for_store/update_service       # Update service
POST /for_store/restart_service      # Restart service

# Tool Operations
GET  /for_store/list_tools           # Get tool list
POST /for_store/use_tool             # Execute tool

# Batch Operations
POST /for_store/batch_add_services   # Batch add
POST /for_store/batch_update_services # Batch update

# Monitoring & Statistics
GET  /for_store/get_stats            # System statistics
GET  /for_store/health               # Health check

Agent Level API ๐Ÿค–

# Fully corresponds to Store level, supports multi-tenant isolation
POST /for_agent/{agent_id}/add_service
GET  /for_agent/{agent_id}/list_services
# ... All Store level features are supported

Monitoring System API (3 endpoints) ๐Ÿ“Š

GET  /monitoring/status              # Get monitoring status
POST /monitoring/config              # Update monitoring configuration
POST /monitoring/restart             # Restart monitoring tasks

General API ๐Ÿ”ง

GET  /services/{name}                # Cross-context service query

Developer Documentation & Resources ๐Ÿ“š

Detailed API Interface Documentation

We provide comprehensive RESTful API documentation aimed at helping developers quickly integrate and debug. The documentation provides comprehensive information for each API endpoint, including:

  • Function Description: Interface purpose and business logic.
  • URL & HTTP Methods: Standard request paths and methods.
  • Request Parameters: Detailed input parameter descriptions, types, and validation rules.
  • Response Examples: Clear success and failure response structure examples.
  • Curl Call Examples: Command-line call examples that can be directly copied and run.
  • Source Code Tracing: Links to backend source code files, classes, and key functions that implement the interface, achieving API-to-code transparency, greatly facilitating in-depth debugging and problem localization ๐Ÿ”.

Source Code Level Development Documentation (LLM-Friendly) ๐Ÿค–

To support deep customization and secondary development, we also provide a unique source code level reference documentation. This documentation not only systematically organizes all core classes, properties, and methods in the project, but more importantly, we additionally provide an LLM-optimized llm.txt version. Developers can directly provide this plain text format documentation to AI models, allowing AI to assist with code understanding, feature extension, or refactoring, thus achieving true AI-Driven Development โœจ.

Contributing ๐Ÿค

MCPStore is an open source project, and we welcome any form of contribution from the community:

  • โญ If the project helps you, please give us a Star on GitHub.
  • ๐Ÿ› Submit bug reports or feature suggestions through Issues.
  • ๐Ÿ”ง Contribute your code through Pull Requests.
  • ๐Ÿ’ฌ Join the community and share your usage experiences and best practices.

MCPStore: Making MCP tool management simple and powerful ๐Ÿ’ช.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpstore-1.2.34.tar.gz (139.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpstore-1.2.34-py3-none-any.whl (155.9 kB view details)

Uploaded Python 3

File details

Details for the file mcpstore-1.2.34.tar.gz.

File metadata

  • Download URL: mcpstore-1.2.34.tar.gz
  • Upload date:
  • Size: 139.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for mcpstore-1.2.34.tar.gz
Algorithm Hash digest
SHA256 1ce7bd8eff6c679a62e5979c7b41d666360461cb03b84e6d8adc44e9c2fab43d
MD5 be33fe092f9d6c0cf27c60177dc01a85
BLAKE2b-256 b8c5df791ac6ecc9f8c673785fcab70aa58529d0bddbdf35d2005cbacfde2ec7

See more details on using hashes here.

File details

Details for the file mcpstore-1.2.34-py3-none-any.whl.

File metadata

  • Download URL: mcpstore-1.2.34-py3-none-any.whl
  • Upload date:
  • Size: 155.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for mcpstore-1.2.34-py3-none-any.whl
Algorithm Hash digest
SHA256 154cb9c1a0bcf678e434c4b4403a5cc035375839ba931b6efa11c9e9d5f941fe
MD5 b30daec889de1d95878e2d7da96e1c72
BLAKE2b-256 cae2e5f793fc0fd0b59dc2d163c4dc44e776cf2edf47918f384662cdf2e8c9f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page