广州MCP服务器

通过模型上下文协议为DAML开发工具提供AI支持。提供代码分析、模式建议和自动化Canton环境管理。
快速开始
# 1. Clone and start with Docker
git clone
cd canton-mcp-server
docker-compose up -d
# 2. Verify it's running
curl http://localhost:7284/health
# 3. Use with Cursor or Claude Desktop
# Add to your MCP config (see Configuration below)服务器URL: http://localhost:7284/mcp
可用工具
daml_reason
分析DAML代码,推荐模式,验证业务逻辑。
用途: 代码审查、模式建议、安全分析
daml_automater
自动化Canton环境、测试和构建。
用途: 启动Canton网络,运行测试,构建DAR
认证
服务器使用 加密挑战-响应身份验证 用于安全方验证。
快速认证(命令行)
# Get JWT token for your Canton party
cd /home/skynet/canton/canton-mcp-client
npm install && npm run build
node dist/auth.js http://localhost:7284 your-party::1220...
# Returns JWT token - use in Authorization headerPython身份验证
import base64, json, requests
from nacl.signing import SigningKey
def authenticate(mcp_url, party_id, key_file):
with open(key_file) as f:
key = json.load(f)
# Request challenge
r = requests.post(f'{mcp_url}/auth/challenge', json={
'partyId': party_id,
'publicKey': key['publicKey']
})
challenge = r.json()['challenge']
# Sign challenge
sk = SigningKey(base64.b64decode(key['privateKey']))
sig = sk.sign(base64.b64decode(challenge)).signature
# Get token
r = requests.post(f'{mcp_url}/auth/verify', json={
'partyId': party_id,
'challenge': challenge,
'signature': base64.b64encode(sig).decode()
})
return r.json()['token']
token = authenticate('http://localhost:7284', 'alice::1220...', '~/.canton/alice-key.json')看 挑战_AUTH_SETUP.md 完整的指南。
配置
对于光标
增添 .cursor/mcp.json:
{
"mcpServers": {
"canton-mcp": {
"type": "sse",
"url": "http://:7284/mcp",
"headers": {
"Authorization": "Bearer "
}
}
}
}备注:替换 `` 使用上述身份验证流中的令牌。 JWT令牌将在1小时后过期,请重新进行身份验证以获取新令牌。
适用于克劳德桌面
增添 claude_desktop_config.json:
{
"mcpServers": {
"canton": {
"command": "docker",
"args": ["exec", "canton-mcp-server", "uv", "run", "canton-mcp-server", "serve"]
}
}
}环境变量
创建 .env.canton:
# Server
MCP_SERVER_URL=http://localhost:7284
# Authentication (REQUIRED)
JWT_SECRET=$(openssl rand -hex 32) # Generate with: openssl rand -hex 32
# x402 Payments (REQUIRED for production)
CANTON_ENABLED=true
CANTON_FACILITATOR_URL=http://46.224.109.63:3000
CANTON_PAYEE_PARTY=damlcopilot-receiver::1220...
CANTON_NETWORK=canton-devnet
# DCAP Performance Tracking (optional)
DCAP_ENABLED=true
DCAP_MULTICAST_IP=159.89.110.236
DCAP_PORT=10191
# Canonical docs path (optional, defaults to ../../canonical-daml-docs)
CANONICAL_DOCS_PATH=/path/to/canonical-daml-docs重要: JWT_SECRET 需要进行身份验证。生成安全密钥:
echo "JWT_SECRET=$(openssl rand -hex 32)" >> .env.canton安装
Docker(推荐)
docker-compose up -d
docker-compose logs -f本地开发
# Using uv (recommended)
uv sync
uv run canton-mcp-server
# Using pip
pip install -e .
canton-mcp-server先决条件
标准DAML文档(必填)
服务器需要访问官方DAML存储库以获得模式建议:
# Create canonical docs directory (parallel to server)
mkdir -p ../canonical-daml-docs
cd ../canonical-daml-docs
# Clone official repos
git clone https://github.com/digital-asset/daml.git
git clone https://github.com/digital-asset/canton.git
git clone https://github.com/digital-asset/daml-finance.git预期结构:
your-projects/
├── canonical-daml-docs/
│ ├── daml/
│ ├── canton/
│ └── daml-finance/
└── canton-mcp-server/通过设置自定义路径 CANONICAL_DOCS_PATH 环境变量(如果需要)。
x402付款
重要: 当使用生产/公共服务器时, 始终包含您的派对ID:
# In headers
X-Canton-Party-ID: your-party::1220abc...
# Or in URL
http://server:7284/mcp?payerParty=your-party::1220abc...如果没有参与方ID,请求将被拒绝 (防止自由访问的安全保护)。
付款流程:
- 工具调用需要付款(每次调用0.10美元)
- 服务器向协调人登记付款要求
- 钱包在广州区块链上执行支付
- 服务器验证付款并处理请求
看 canton-x402-协调员 用于支付基础设施设置。
测试
# List available tools
curl -X POST http://localhost:7284/mcp \
-H "Content-Type: application/json" \
-H "X-Canton-Party-ID: your-party::123" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# Call daml_reason
curl -X POST http://localhost:7284/mcp \
-H "Content-Type: application/json" \
-H "X-Canton-Party-ID: your-party::123" \
-d '{
"jsonrpc":"2.0",
"id":2,
"method":"tools/call",
"params":{
"name":"daml_reason",
"arguments":{"businessIntent":"Create a simple IOU contract"}
}
}'
# Interactive testing
npx @modelcontextprotocol/inspector http://localhost:7284/mcp文档
- CANTON_X402_INTEGRATION.md -支付集成指南
- DEPLOYMENT_SETUP.md -生产部署
- 快速启动.md -详细的设置指南
发展
# Install dev dependencies
uv sync --dev
# Run server
uv run python -m canton_mcp_server.server
# Run tests
pytest建筑
简单堆栈:
- 具有HTTP+SSE传输的FastAPI服务器
- 两个MCP工具(daml_reason、daml_automater)
- x402支付集成(广州币)
- DCAP性能跟踪
- 标准资源推荐
支付理念:
- 无利率限制(付款是限制因素)
- 无身份验证(设计无需许可)
- 单一要求:付款证明
贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 提交拉取请求
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
