使用说明
Axum HTTP MCP服务器
构建
git clone https://github.com/apepkuss/axum-http-mcp-server.git
cd axum-http-mcp-server
cargo build --release
跑
- 安装WasmEdge运行时
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install_v2.sh | bash -s -- -v 0.14.1
-
启动服务器
wasmedge --dir .:. ./target/wasm32-wasip1/release/axum-mcp-server.wasm -
测试服务器
-
调用“计数器”工具以递增计数器
curl -X POST http://localhost:10086/api/counter \ --header "Content-Type: application/json" \ --data '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "counter", "arguments": { "operation": "increment" } } }'答复:
{ "id": 5, "jsonrpc": "2.0", "result": { "value": 1 } } -
调用“计数器”工具以递减计数器
curl -X POST http://127.0.0.1:10086/api/counter \ --header "Content-Type: application/json" \ --data '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "counter", "arguments": { "operation": "decrement" } } }'答复:
{ "id": 5, "jsonrpc": "2.0", "result": { "value": 0 } } -
调用“计数器”工具获取计数器值
curl -X POST http://127.0.0.1:10086/api/counter \ --header "Content-Type: application/json" \ --data '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "counter", "arguments": { "operation": "get_value", } } }'答复:
{ "id": 5, "jsonrpc": "2.0", "result": { "value": 0 } }
-