Lab 08 - 11: Testing
# Step 11: Testing with MCP Inspector
## Build and Run
```bash
# Build the TypeScript code
npm run build
# Start the server in development mode
npm run dev
```
Using MCP Inspector
MCP Inspector is a web-based debugging tool for MCP servers.
Start Inspector
This will:
- Start your K-Agent server
- Launch MCP Inspector web interface
- Open your browser automatically
Connect to Server
- Click the “Connect” button at the bottom left
- Wait for “Connected” status (green indicator)
- You should see “k-agent-logs v1.0.0” in the title
Test list_pods Tool
- Click the “Tools” tab
- Click “List Tools” to refresh
- Click on
list_pods - Optionally enter a namespace in the input field
- Click “Run Tool”
Expected Result:
[
{
"name": "coredns-abc123",
"namespace": "kube-system",
"status": "Running",
"containers": ["coredns"]
}
]
Test collect_pod_logs Tool
- Click on
collect_pod_logsin the tools list - In the namespace field, enter:
kube-system - Optionally specify a podName
- Set tailLines to
50 - Click “Run Tool”
Expected Result:
=== coredns-abc123/coredns ===
2024-01-15T10:30:45.123Z [INFO] CoreDNS-1.11.1
2024-01-15T10:30:45.124Z linux/amd64, go1.21.1
...
Troubleshooting
| Issue | Solution |
|---|---|
| “Cannot connect” | Ensure server is running |
| “Permission denied” | Check kubectl permissions |
| “No pods found” | Verify cluster is running |
| “Timeout” | Increase wait time, check cluster |
Alternative: Manual Testing
You can also test by piping JSON-RPC messages: