Loading files
# MCP Server Service Test
Test code for launching an MCP server with Moddable.
## Running (Linux)
```bash
cd tests/services/mcp-server-service
source ~/.local/share/xs-dev-export.sh
mcconfig -m -d -p lin
```
## Testing
Once the server is running, you can test it with the following commands:
### 1. Health Check
```bash
curl http://localhost:8080/health
```
### 2. MCP Protocol Initialization
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"initialize","params":{}}'
```
### 3. List Available Tools
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"2","method":"tools/list","params":{}}'
```
### 4. Execute Tool (Hello World)
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"hello_world","arguments":{"name":"Stack-chan"}}}'
```
### 5. Execute Tool (Numeric Calculation)
```bash
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"4","method":"tools/call","params":{"name":"add_numbers","arguments":{"a":10,"b":20}}}'
```
## Implemented Tools
- **hello_world**: Returns a greeting message
- **add_numbers**: Adds two numbers
- **get_current_time**: Returns the current time
f28aa5c47This file is pinned to the selected release. Download the original to open it in your design tool.