关于 easyMcp
easyMcp 是供开发者搭建可扩展 MCP 服务的框架,支持 STDIO、SSE 和 Streamable Http 传输方式。自定义工具通过继承 `BaseHandler` 的处理类添加。
主要功能
- 01支持 STDIO、SSE 和 Streamable Http
- 02基于处理类的可扩展工具结构
- 03工具描述与执行方法
- 04可选的环境配置
适用场景
- 01选择传输方式搭建 MCP 服务
- 02以处理类添加自定义工具
MCP 相关
该框架用于构建 MCP 服务,并通过 STDIO、SSE 或 Streamable Http 向 MCP 客户端提供自定义处理工具。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
暂未收录安装方式
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
easyMcp
只需两个步骤,即可快速构建一个易于扩展、支持所有 Model Context Protocol(MCP)传输模式(STDIO、SSE、Streamable Http)的 MCP 服务框架。
朋友们,请点个赞!
用户手册
1. 步骤一 [可选] 定义所需的配置信息
在 src/config/.env 中定义项目所需的配置信息。例如,如果需要数据库配置:
# MySQL Database Configuration
MYSQL_HOST=192.168.3.229
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=a_llm
MYSQL_ROLE=admin
2. 步骤二 创建自己的工具
在 src/handles 目录中添加自己的工具类,参考 example.py 示例
- 继承 BaseHandler
- 定义
name属性,即工具的名称 - 定义
description属性,即工具的描述 - 实现
get_tool_description方法,告知 MCP 客户端该工具的功能 - 实现
run_tool方法,这是 MCP 客户端调用工具的方法;在此处实现工具逻辑 - 在
__init__.py中导入新工具
example.py
from typing import Dict, Any, Sequence
from mcp import Tool
from mcp.types import TextContent
from .base import BaseHandler
from config import get_config
class Example(BaseHandler):
name = "get_Example"
description = (
"this is Example xxxx"
)
def get_tool_description(self) -> Tool:
return Tool(
name=self.name,
description=self.description,
inputSchema={
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "This is the text that must be entered for the example"
}
},
"required": ["text"]
}
)
async def run_tool(self, arguments: Dict[str, Any]) -> Sequence[TextContent]:
try:
if "text" not in arguments:
raise ValueError("Missing text content")
text = arguments["text"]
# Reference configuration information
config = get_config()
## todo something
result = "xxxxxxx"
# Join all results with commas
return [TextContent(type="text", text=','.join(result))]
except Exception as e:
return [TextContent(type="text", text=f"error: {str(e)}")]
init.py
from .example import Example
__all__ = [
"Example",
]
3. 启动
目前,此框架支持所有 Model Context Protocol(MCP)传输模式(STDIO、SSE、Streamable Http)。
1. Streamable Http 模式
- 使用 uv 启动服务
将以下内容添加到 MCP 客户端工具中,例如 cursor、cline 等。
MCP JSON 示例:
{
"mcpServers": {
"easyMcp": {
"name": "easyMcp",
"type": "streamableHttp",
"description": "",
"isActive": true,
"baseUrl": "http://localhost:3000/mcp/"
}
}
}
启动命令
# Install dependencies
uv sync
# Start
uv run src/server.py
2. SSE 模式
- 使用 uv 启动服务
将以下内容添加到 MCP 客户端工具中,例如 cursor、cline 等。
MCP JSON 示例:
{
"mcpServers": {
"easyMcp": {
"name": "easyMcp",
"description": "",
"isActive": true,
"baseUrl": "http://localhost:9000/sse"
}
}
}
启动命令
# Install dependencies
uv sync
# Start
uv run src/server.py --sse
3. STDIO 模式
将以下内容添加到 MCP 客户端工具中,例如 cursor、cline 等。
MCP JSON 示例:
{
"mcpServers": {
"operateMysql": {
"isActive": true,
"name": "operateMysql",
"command": "uv",
"args": [
"--directory",
"G:\\python\\mysql_mcp\\src", # Replace this with your project path
"run",
"server.py",
"--stdio"
],
"env": {
"MYSQL_HOST": "192.168.xxx.xxx",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "root",
"MYSQL_DATABASE": "a_llm",
"MYSQL_ROLE": "admin"
}
}
}
}
截图
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。