开源工具让任何 LLM(不仅 Claude)都能接入 MCP 生态,扩展 AI 能力范围。对 AI 应用开发者是实用工具升级。
尝试新的 beta v2,使用命令 create-mcp-use-app@beta:npx create-mcp-use-app@beta。详见 beta README。
mcp-use 是一个全栈 MCP 框架,用于为 ChatGPT / Claude 构建 MCP Apps,以及为 AI Agents 构建 MCP Servers。
使用 mcp-use SDK(TypeScript | Python)构建:MCP Servers 和 MCP Apps
在 mcp-use MCP Inspector 上预览(在线 | 开源):测试和调试你的 MCP Servers 和 Apps
部署到 Manufact MCP Cloud:连接你的 GitHub 仓库,让你的 MCP Server 和 App 在生产环境中运行,配备可观测性、指标、日志、分支部署等功能
访问我们的文档或跳转到快速开始指南(TypeScript | Python)
使用 Claude Code、Codex、Cursor 或其他 AI 编码 Agent?
安装 mcp-use 技能用于构建 MCP Apps
构建你的第一个 MCP Server 或 MPC App:
npx create-mcp-use-app@latest
或手动创建一个 Server:
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/inspector
→ 完整 TypeScript Server 文档
MCP Apps 允许你构建交互式小部件,可以跨 Claude、ChatGPT 和其他 MCP 客户端工作——一次编写,到处运行。
Server:定义一个工具并指向一个小部件:
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);
小部件:在 resources/weather-display/widget.tsx 中创建一个 React 组件:
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<z.infer<typeof propSchema>>();
const isDark = theme === "dark";
if (isPending) return <div>Loading...</div>;
return (
<div style={{
background: isDark ? "#1a1a2e" : "#f0f4ff",
borderRadius: 16, padding: 24,
}}>
<h2>{props.city}</h2>
<p>{props.temperature}° — {props.conditions}</p>
</div>
);
};
export default WeatherDisplay;
resources/ 中的小部件会被自动发现——不需要手动注册。
访问 MCP Apps 文档
可以一键部署或作为你自己的项目重新混合的现成 MCP Apps。
pip install mcp-use
from 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
→ 完整 Python Server 文档
mcp-use Inspector 让你交互式地测试和调试你的 MCP Server。
使用 server.listen() 时自动包含:
server.listen(3000);
// Inspector at http://localhost:3000/inspector
连接到托管 MCP Server 时在线:
访问 https://inspector.mcp-use.com
独立使用:检查任何 MCP Server:
npx @mcp-use/inspector --url http://localhost:3000/mcp
访问 Inspector 文档
将你的 MCP Server 部署到生产环境:
npx @mcp-use/cli login
npx @mcp-use/cli deploy
或在 manufact.com 上连接你的 GitHub 仓库——生产就绪,配备可观测性、指标、日志和分支部署。
这个单仓库包含 Python 和 TypeScript 的多个包。
mcp-use 还提供了完整的 MCP Agent 和 Client 实现。
pip install mcp-use langchain-openai
import 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())
→ 完整 Python Agent 文档
npm install mcp-use @langchain/openai
import { 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();
→ 完整 TypeScript Agent 文档
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())
→ Python Client 文档
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();
→ TypeScript Client 文档
Discord:加入我们的社区
GitHub Issues:报告 bug 或请求功能
网站:manufact.com
X.com:关注 Manufact
贡献:见 CONTRIBUTING.md
许可证:MIT © MCP-Use 贡献者
感谢所有我们了不起的贡献者!
Pietro (@pietrozullo)