mcpbuilder-ai
Connect your apps to AI-powered MCP servers — in minutes, not months.
mcpbuilder-ai is the official SDK for MCP-Builder.ai, available for both Python and TypeScript.
Stream chat responses, execute tools with consent handling, and manage authentication — all through a clean, callback-driven API over WebSockets.
Build your MCP server on the MCP-Builder.ai dashboard, grab your project token, and start talking to it from any app with just a few lines of code.
______________________________________________________________________
运作原理
┌─────────────────────┐ ┌──────────────────────────┐
│ Your Application │ SDK │ MCP-Builder.ai Cloud │
│ │ ─────► │ │
│ - Web frontend │ WS │ - MCP Server you built │
│ - CLI tool │ ◄───── │ - Tool execution │
│ - Backend service │ │ - LLM orchestration │
└─────────────────────┘ └──────────────────────────┘- 设计 您的MCP服务器位于 mcp-builder.ai --配置工具,连接API,设置身份验证。
- 安装 SDK(
pip install mcpbuilder-ai/npm install mcpbuilder-ai). - 连接 使用您的项目令牌和部署名称。
- 聊天 --实时流式传输令牌、处理工具调用、管理同意流。
______________________________________________________________________
特性
| Python | TypeScript | |
|---|---|---|
| 实时令牌流 | ✅ | ✅ |
| Fluent回调API | ✅ | ✅ |
| 工具同意处理 | ✅ | ✅ |
| 通过回退自动重新连接 | ✅ | ✅ |
| 会话和历史管理 | ✅ | ✅ |
| 安全参数覆盖 | ✅ | ✅ |
| 全型安全 | ✅ (键入提示) | ✅ (TypeScript泛型) |
| ESM+CommonJS | -- | ✅ |
______________________________________________________________________
快速开始
TypeScript
npm install mcpbuilder-aiimport { MCPChatClient } from 'mcpbuilder-ai';
const client = new MCPChatClient({
projectToken: 'your-project-token',
deploymentName: 'my-deployment',
cacheHistory: false,
});
client
.onToken((token) => process.stdout.write(token))
.onFinal((text, toolCalls) => console.log('\nDone!'))
.onError((error) => console.error('Error:', error));
await client.connect();
await client.sendMessage('Hello, what can you do?');python
pip install mcpbuilder-aiimport asyncio
from mcpbuilder import MCPChatClient
async def main():
client = MCPChatClient(
project_token="your-project-token",
deployment_name="my-deployment",
cache_history=False,
)
client \
.on_token(lambda t: print(t, end="", flush=True)) \
.on_final(lambda text, tc: print("\nDone!")) \
.on_error(lambda msg: print(f"Error: {msg}"))
await client.connect()
await client.send_message("Hello, what can you do?")
asyncio.run(main())______________________________________________________________________
SDK文档
| SDK | 软件包 | 文档 |
|---|---|---|
| TypeScript | TypeScript自述 | |
python mcpbuilder-ai 在PyPI上 | Python自述 |
______________________________________________________________________
集成示例
这 例子 目录包含可运行的项目,显示如何连接到构建在其上的MCP服务器 MCP-Builder.ai:
| 示例 | 语言 | 描述 |
|---|---|---|
| React MCP聊天 | TypeScript | 基于React的聊天UI,支持流媒体+工具同意 |
| 简单的Python命令行界面 | Python | 带有实时令牌流的终端聊天客户端 |
新加入MCP-Builder.ai? 检查 入门指南 创建您的第一个项目并获取项目令牌。
______________________________________________________________________
MCP-Builder.ai入门
- 注册 在 mcp-builder.ai 然后打开仪表板。
- 创建项目 --定义您的工具,连接外部API,并配置身份验证。
- 部署 只需单击一下即可访问您的MCP服务器。
- 复制 仪表板中的项目令牌和部署名称。
- 安装 SDK并将凭据粘贴到您的应用程序中——您就可以使用了。
______________________________________________________________________
贡献
欢迎投稿!请随时打开问题或提交pull请求。
许可证
Apache-2.0--有关详细信息,请参阅\[LICENSE\]。
