内容
# Axum-HTTP-MCP-Server
## 构建
```bash
git clone https://github.com/apepkuss/axum-http-mcp-server.git
cd axum-http-mcp-server
cargo build --release
```
## 运行
- 安装 WasmEdge Runtime
```bash
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install_v2.sh | bash -s -- -v 0.14.1
```
- 启动服务器
```bash
wasmedge --dir .:. ./target/wasm32-wasip1/release/axum-mcp-server.wasm
```
- 测试服务器
- 调用 "counter" 工具来增加计数器
```bash
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"
}
}
}'
```
响应:
```json
{
"id": 5,
"jsonrpc": "2.0",
"result": {
"value": 1
}
}
```
- 调用 "counter" 工具来减少计数器
```bash
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"
}
}
}'
```
响应:
```json
{
"id": 5,
"jsonrpc": "2.0",
"result": {
"value": 0
}
}
```
- 调用 "counter" 工具来获取计数器值
```bash
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"
}
}
}'
```
响应:
```json
{
"id": 5,
"jsonrpc": "2.0",
"result": {
"value": 0
}
}
```