## 安装
pip install dedalus-mcp dedalus-labs
## API 密钥
在控制台中获取你的 API 密钥并进行设置:
export DEDALUS_API_KEY="your-api-key"
## 创建服务端
# server.py
from dedalus_mcp import MCPServer, tool
@tool(description="Add two numbers")
def add(a: int, b: int) -> int:
return a + b
@tool(description="将两个数相乘")
def multiply(a: int, b: int) -> int:
return a * b
server = MCPServer("calculator")
server.collect(add, multiply)
if __name__ == "__main__":
import asyncio
asyncio.run(server.serve())
运行它:
服务器在 http://127.0.0.1:8000/mcp 上启动。
使用 Client 进行测试
# client.py
from dedalus_mcp.client import MCPClient
import asyncio
async def main():
client = await MCPClient.connect("http://127.0.0.1:8000/mcp")
# 列出可用工具
tools = await client.list_tools()
print([t.name for t in tools.tools]) # ['add', 'multiply']
# 调用工具
result = await client.call_tool("add", {"a": 2, "b": 3})
print(result.content[0].text) # "5"
await client.close()
asyncio.run(main())
准备好在远程托管你的服务器了吗?部署到 Dedalus 平台即可从任何地方访问、与他人共享,或对你的成果进行变现。
后续步骤
身份验证
行业内最安全的模型上下文协议 (MCP) 身份验证框架。
示例
用于生产环境服务器的示例(如 GitHub 和 Supabase)。
Last modified on April 11, 2026