关于
mcp使用 是全栈MCP框架 为ChatGPT/Claude构建MCP应用程序,为AI代理构建MCP服务器。
- 部署 上 宏发MCP云:连接您的GitHub仓库,让您的MCP服务器和应用程序在生产环境中运行,并具有可观察性、指标、日志、分支部署等功能
文档
访问我们的 文档 或者跳到快速入门(TypeScript | python)
编码代理的技能
使用Claude Code、Codex、Cursor或其他AI编码代理? 安装mcp应用程序的mcp使用技巧
快速入门:MCP服务器和MCP应用程序
TypeScript
构建您的第一个MCP服务器或MPC应用程序:
npx create-mcp-use-app@latest或者手动创建服务器:
import { MCPServer, text } from "mcp-use/server";
import { z } from "zod";
const server = new MCPServer({
name: "my-server",
version: "1.0.0",
});
server.tool({
name: "get_weather",
description: "Get weather for a city",
schema: z.object({ city: z.string() }),
}, async ({ city }) => {
return text(`Temperature: 72°F, Condition: sunny, City: ${city}`);
});
await server.listen(3000);
// Inspector at http://localhost:3000/inspectorMCP应用程序
MCP应用程序允许您构建跨Claude、ChatGPT和其他MCP客户端工作的交互式小部件——一次编写,随处运行。
服务器:定义一个工具并将其指向一个小部件:
import { MCPServer, widget } from "mcp-use/server";
import { z } from "zod";
const server = new MCPServer({
name: "weather-app",
version: "1.0.0",
});
server.tool({
name: "get-weather",
description: "Get weather for a city",
schema: z.object({ city: z.string() }),
widget: "weather-display", // references resources/weather-display/widget.tsx
}, async ({ city }) => {
return widget({
props: { city, temperature: 22, conditions: "Sunny" },
message: `Weather in ${city}: Sunny, 22°C`,
});
});
await server.listen(3000);小部件:在中创建一个React组件 resources/weather-display/widget.tsx:
import { useWidget, type WidgetMetadata } from "mcp-use/react";
import { z } from "zod";
const propSchema = z.object({
city: z.string(),
temperature: z.number(),
conditions: z.string(),
});
export const widgetMetadata: WidgetMetadata = {
description: "Display weather information",
props: propSchema,
};
const WeatherDisplay: React.FC = () => {
const { props, isPending, theme } = useWidget>();
const isDark = theme === "dark";
if (isPending) return
Loading...
;
return (
{props.city}
{props.temperature}° — {props.conditions}
);
};
export default WeatherDisplay;小工具在 resources/ 是 自动发现 --无需手动注册。
访问 MCP应用程序文档
______________________________________________________________________
python
pip install mcp-usefrom typing import Annotated
from mcp.types import ToolAnnotations
from pydantic import Field
from mcp_use import MCPServer
server = MCPServer(name="Weather Server", version="1.0.0")
@server.tool(
name="get_weather",
description="Get current weather information for a location",
annotations=ToolAnnotations(readOnlyHint=True, openWorldHint=True),
)
async def get_weather(
city: Annotated[str, Field(description="City name")],
) -> str:
return f"Temperature: 72°F, Condition: sunny, City: {city}"
# Start server with auto-inspector
server.run(transport="streamable-http", port=8000)
# 🎉 Inspector at http://localhost:8000/inspector______________________________________________________________________
检查员
mcp-use Inspector允许您交互式地测试和调试mcp服务器。
包括汽车 使用时 server.listen():
server.listen(3000);
// Inspector at http://localhost:3000/inspector在线的 连接到托管的MCP服务器时:
访问https://inspector.mcp-use.com
独立:检查任何MCP服务器:
npx @mcp-use/inspector --url http://localhost:3000/mcp访问 检查员文件
______________________________________________________________________
部署
将MCP服务器部署到生产环境:
npx @mcp-use/cli login
npx @mcp-use/cli deploy或者将您的GitHub仓库连接到 manufact.com --生产就绪,具有可观察性、度量、日志和分支部署。
______________________________________________________________________
包装概述
这个monorepo包含Python和TypeScript的多个包:
Python 包
| 包 | 描述 | 版本 |
|---|---|---|
| mcp使用 | 完整的MCP服务器和MCP代理SDK |  |
TypeScript软件包
| 包 | 描述 | 版本 |
|---|---|---|
| mcp使用 | MCP服务器、MCP应用程序和MCP代理的核心框架 | ](https://www.npmjs.com/package/mcp-use) |
| @mcp使用/cli | 带有热装和自动检查器的构建工具 | ](https://www.npmjs.com/package/@mcp-use/cli) |
| @mcp使用/检查员 | 用于MCP服务器的基于Web的预览器和调试器 | ](https://www.npmjs.com/package/@mcp-use/inspector) |
| 创建mcp使用应用程序 | 项目脚手架工具 | ](https://www.npmjs.com/package/create-mcp-use-app) |
______________________________________________________________________
另外:MCP代理和客户
mcp的使用还提供了完整的mcp代理和客户端实现。
Build an AI Agent
python
pip install mcp-use langchain-openaiimport asyncio
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def main():
config = {
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}
client = MCPClient.from_dict(config)
llm = ChatOpenAI(model="gpt-4o")
agent = MCPAgent(llm=llm, client=client)
result = await agent.run("List all files in the directory")
print(result)
asyncio.run(main())TypeScript
npm install mcp-use @langchain/openaiimport { ChatOpenAI } from "@langchain/openai";
import { MCPAgent, MCPClient } from "mcp-use";
async function main() {
const config = {
mcpServers: {
filesystem: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
},
},
};
const client = MCPClient.fromDict(config);
const llm = new ChatOpenAI({ modelName: "gpt-4o" });
const agent = new MCPAgent({ llm, client });
const result = await agent.run("List all files in the directory");
console.log(result);
}
main();Use MCP Client
python
import asyncio
from mcp_use import MCPClient
async def main():
config = {
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"]
}
}
}
client = MCPClient.from_dict(config)
await client.create_all_sessions()
session = client.get_session("calculator")
result = await session.call_tool(name="add", arguments={"a": 5, "b": 3})
print(f"Result: {result.content[0].text}")
await client.close_all_sessions()
asyncio.run(main())TypeScript
import { MCPClient } from "mcp-use";
async function main() {
const config = {
mcpServers: {
calculator: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-everything"],
},
},
};
const client = new MCPClient(config);
await client.createAllSessions();
const session = client.getSession("calculator");
const result = await session.callTool("add", { a: 5, b: 3 });
console.log(`Result: ${result.content[0].text}`);
await client.closeAllSessions();
}
main();______________________________________________________________________
符合模型上下文协议
______________________________________________________________________
社区与支持
- Discord 的中文翻译是“不和谐”或“纷争”。: 加入我们的社区
- GitHub问题: 报告错误或请求功能
- 文档: mcp-use.com/docs
- 网站: manufact.com
- X.com:关注 制造
- 贡献:参见 贡献.md
- 许可证:MIT© MCP使用贡献者
______________________________________________________________________
星迹

______________________________________________________________________
贡献者
感谢我们所有出色的贡献者!
核心贡献者
- 彼得罗 (@皮埃特罗祖洛)
- 路易吉 (@函数=随机(浮点)@描述=随机(浮点数)@描述=RAND(浮点))
- 恩里科 (@tonxxd)
______________________________________________________________________
Built with ❤️ by Manufact team and the mcp-use community
San Francisco | Zürich
