Token导航 LogoToken导航TokenDH.com
MCP Local Remote Client logo
AI代理stdio官方级别未说明来源级核验

MCP Local Remote Client

MCP Server

一个实现模型上下文协议(MCP)的开源项目,提供标准化接口连接AI系统与外部工具、服务和数据源,支持文件读取、函数执行和上下文管理。

工具数

3

提示词数

0

GitHub Stars

1

资源数

0
开源项目PythonClaude上下文管理ClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

SaeedAngiz1

提供方

SaeedAngiz1

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

模型上下文协议(MCP)项目

模型上下文协议(MCP)的全面实现,MCP是连接人工智能系统,特别是大型语言模型(LLM)与外部工具、服务和数据源的开放标准。

📋 目录

🎯 什么是MCP?

模型上下文协议(MCP)是Anthropic引入的一个开放标准,它规范了人工智能系统与外部工具和数据源的集成。它提供:

  • 通用接口:用于读取文件、执行函数和处理上下文提示
  • 客户端-服务器体系结构:实现安全的双向通信
  • 工具集成:将LLM连接到数据库、API、文件系统等
  • 上下文管理:为AI模型提供上下文的结构化方法

📁 项目结构

mcp-project/
├── README.md                 # This file
├── requirements.txt          # Python dependencies
├── .gitignore               # Git ignore rules
├── config/
│   └── mcp_config.json      # MCP server configuration
├── src/
│   ├── __init__.py
│   ├── mcp_server.py        # Main MCP server implementation
│   ├── tools/               # Custom MCP tools
│   │   ├── __init__.py
│   │   ├── file_tools.py   # File system operations
│   │   ├── api_tools.py    # API integration tools
│   │   └── data_tools.py   # Data processing tools
│   └── utils/
│       ├── __init__.py
│       └── helpers.py      # Utility functions
├── examples/
│   ├── basic_server.py     # Basic MCP server example
│   ├── client_example.py   # MCP client example
│   └── custom_tools.py     # Custom tools example
├── tests/
│   ├── __init__.py
│   └── test_mcp_server.py  # Unit tests
└── docs/
    ├── ARCHITECTURE.md     # Architecture documentation
    └── TUTORIAL.md         # Detailed tutorial

🚀 分步设置指南

💡 Windows CMD用户:参见 SETUP_CMD.md 获取包含所有命令的完整CMD特定指南。

第一步:先决条件

确保已安装以下内容:

  • Python 3.9或更高版本
  • pip(Python包管理器)
  • Git

步骤2:克隆或初始化存储库

Windows CMD:

mkdir mcp-project
cd mcp-project
git init

macOS/Linux:

mkdir mcp-project
cd mcp-project
git init

步骤3:创建虚拟环境

Windows CMD:

python -m venv venv
venv\Scripts\activate.bat

Windows PowerShell:

python -m venv venv
venv\Scripts\Activate.ps1

macOS/Linux:

python3 -m venv venv
source venv/bin/activate

步骤4:安装依赖项

Windows CMD/PowerShell:

pip install -r requirements.txt

macOS/Linux:

pip install -r requirements.txt

步骤5:安装MCP SDK

# Install the official MCP Python SDK
pip install mcp

# Or install from source
pip install git+https://github.com/modelcontextprotocol/python-sdk.git

步骤6:配置MCP服务器

  1. 编辑 config/mcp_config.json 配置服务器设置
  2. 定义您的工具和资源
  3. 如果需要,设置身份验证

步骤7:运行示例服务器

Windows CMD:

REM Run the basic example
python examples\basic_server.py

REM Or run the full server
python src\mcp_server.py

macOS/Linux:

# Run the basic example
python examples/basic_server.py

# Or run the full server
python src/mcp_server.py

步骤8:测试实现

Windows CMD:

REM Run tests
python -m pytest tests\

REM Or run manually
python examples\client_example.py

macOS/Linux:

# Run tests
pytest tests/

# Or run manually
python examples/client_example.py

✨ 特性

  • MCP服务器实现:功能齐全的MCP服务器,支持工具
  • 自定义工具:文件操作、API调用和数据处理示例
  • 客户端集成:连接到MCP服务器的示例客户端
  • 配置管理:基于JSON的配置系统
  • 错误处理:强大的错误处理和日志记录
  • 类型安全:在整个代码库中键入提示
  • 测试:核心功能的单元测试

📖 用法

启动MCP服务器

from src.mcp_server import MCPServer

# Initialize server
server = MCPServer(config_path="config/mcp_config.json")

# Start server
server.start()

使用MCP工具

from src.tools.file_tools import FileTools

# Initialize file tools
file_tools = FileTools()

# Read a file
content = file_tools.read_file("path/to/file.txt")

# Write to a file
file_tools.write_file("path/to/file.txt", "content")

客户端连接

from src.mcp_client import MCPClient

# Connect to MCP server
client = MCPClient(server_url="http://localhost:8000")

# Call a tool
result = client.call_tool("read_file", {"path": "example.txt"})

🎓 例子

请参阅 examples/ 目录:

  • basic_server.py:最低限度的MCP服务器实现
  • 客户端示例.py:如何连接和使用MCP服务器
  • custom_tools.py:创建自定义MCP工具

🏗️ 建筑

MCP遵循客户端-服务器架构:

┌─────────────┐         ┌─────────────┐         ┌─────────────┐
│   LLM App   │◄───────►│ MCP Client  │◄───────►│ MCP Server  │
│  (Claude)   │         │             │         │             │
└─────────────┘         └─────────────┘         └──────┬──────┘
                                                        │
                                                ┌────────┴────────┐
                                                │                 │
                                         ┌──────▼──────┐  ┌──────▼──────┐
                                         │   Tools     │  │  Resources  │
                                         │  (Actions)  │  │   (Data)    │
                                         └─────────────┘  └─────────────┘

关键部件:

  1. MCP服务器:为客户提供工具和资源
  2. MCP客户端:连接到服务器并发出请求
  3. 工具:可执行函数(例如,read_file、call_api)
  4. 资源:数据源(如文件、数据库)

🔧 发展

添加自定义工具

  1. 在中创建新文件 src/tools/
  2. 按照MCP工具界面执行工具功能
  3. 在中注册工具 mcp_server.py

例子:

from mcp import Tool

@Tool(name="my_custom_tool", description="Does something custom")
def my_custom_tool(param: str) -> str:
    # Your implementation
    return result

运行测试

# Run all tests
pytest

# Run with coverage
pytest --cov=src tests/

🔌 集成

该项目包括流行工具和服务的全面集成指南:

- LM工作室 - Docker 桌面版 - Obsidian(本地REST API和Marcel Marais的服务器) - Logseq - 光标IDE - 克劳德·索内特 - 云服务器设置

- 将LM Studio与游标连接 - 测试连接 - 在Cursor中使用LM Studio工具 - 通过iPhone A-Shell和Tailscale进行远程访问 - 常见问题排查

- 从iPhone/Android访问LM Studio - 尾秤设置和配置 - A-Shell(iOS)和Termux(Android)的使用 - SSH隧道方法 - 安全最佳实践

📚 资源

🤝 贡献

欢迎投稿!请随时提交拉取请求。

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/AmazingFeature)
  3. 提交您的更改(git commit -m 'Add some AmazingFeature')
  4. 推到分支(git push origin feature/AmazingFeature)
  5. 打开拉取请求

📝 许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

🙏 致谢

  • 创建模型上下文协议的拟人化
  • MCP社区的贡献和支持

______________________________________________________________________

由以下材料制成❤️ 对于MCP社区

目录标签

目录标签

开源项目PythonClaude上下文管理AI集成本地部署协议标准工具连接

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP