安装
API 密钥
创建服务端
http://127.0.0.1:8000/mcp 上启动。
使用 Client 进行测试
部署
部署指南
带截图的逐步部署向导。
5 分钟内即可构建并部署一个模型上下文协议 (MCP) 服务器。
pip install dedalus-mcp dedalus-labs
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())
python server.py
http://127.0.0.1:8000/mcp 上启动。
# 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']
# Call a tool
result = await client.call_tool("add", {"a": 2, "b": 3})
print(result.content[0].text) # "5"
await client.close()
asyncio.run(main())
此页面对您有帮助吗?