|
| 1 | +# MCP Quickstart Smoke Tests |
| 2 | + |
| 3 | +This directory contains smoke tests for the MCP quickstart examples. These tests verify that all example servers and clients can start and respond correctly, without calling external APIs. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The smoke tests verify: |
| 8 | + |
| 9 | +- **Servers**: Each weather server (Python, TypeScript, Rust) can start and respond to MCP protocol requests |
| 10 | +- **Clients**: Each MCP client (Python, TypeScript) can connect to a mock server and list tools |
| 11 | + |
| 12 | +## Running Tests |
| 13 | + |
| 14 | +```bash |
| 15 | +./tests/smoke-test.sh |
| 16 | +``` |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +- **Node.js** 16+ |
| 21 | +- **npm** (for Node.js dependencies) |
| 22 | +- **Python** 3.10+ |
| 23 | +- **uv** (Python package manager) |
| 24 | +- **Rust** stable |
| 25 | +- **Cargo** (for Rust builds) |
| 26 | + |
| 27 | +## How It Works |
| 28 | + |
| 29 | +### Server Tests |
| 30 | + |
| 31 | +Each server test: |
| 32 | + |
| 33 | +1. Builds/prepares the server if needed |
| 34 | +2. Uses `mcp-test-client.ts` to connect to the server via stdio |
| 35 | +3. Sends MCP initialize and `tools/list` requests |
| 36 | +4. Verifies the server responds with a valid tool list |
| 37 | +5. Reports pass/fail |
| 38 | + |
| 39 | +### Client Tests |
| 40 | + |
| 41 | +Each client test: |
| 42 | + |
| 43 | +1. Builds/prepares the client if needed |
| 44 | +2. Runs the client CLI without an ANTHROPIC_API_KEY |
| 45 | +3. The client connects to a mock server, lists tools, and exits gracefully |
| 46 | +4. Verifies the client can connect and communicate via MCP protocol |
| 47 | +5. Reports pass/fail |
| 48 | + |
| 49 | +**Note**: Client tests run the actual CLI programs without an Anthropic API key. The clients are designed to handle missing API keys gracefully by listing available tools and exiting, which is perfect for smoke testing the MCP connectivity without requiring external API calls. |
| 50 | + |
| 51 | +## Test Helpers |
| 52 | + |
| 53 | +### mcp-test-client.ts |
| 54 | + |
| 55 | +A minimal MCP client that connects to a server, initializes the session, and lists available tools. Used to test servers without requiring a full client implementation. |
| 56 | + |
| 57 | +**Usage**: |
| 58 | + |
| 59 | +```bash |
| 60 | +node tests/helpers/build/mcp-test-client.js <command> [args...] |
| 61 | +``` |
| 62 | + |
| 63 | +**Example**: |
| 64 | + |
| 65 | +```bash |
| 66 | +node tests/helpers/build/mcp-test-client.js python weather.py |
| 67 | +``` |
| 68 | + |
| 69 | +### mock-mcp-server.ts |
| 70 | + |
| 71 | +A minimal MCP server that verifies clients call the `tools/list` method and returns an empty tool list. Used to test clients without requiring a real weather server. Exits with an error if the client doesn't call `tools/list`. |
| 72 | + |
| 73 | +**Usage**: |
| 74 | + |
| 75 | +```bash |
| 76 | +node tests/helpers/build/mock-mcp-server.js |
| 77 | +``` |
| 78 | + |
| 79 | +## CI/CD Integration |
| 80 | + |
| 81 | +Tests run automatically on pull requests via GitHub Actions. See `.github/workflows/ci.yml` for the CI configuration. |
| 82 | + |
| 83 | +## Troubleshooting |
| 84 | + |
| 85 | +### Dependencies missing |
| 86 | + |
| 87 | +Install required dependencies: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Python/uv |
| 91 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 92 | + |
| 93 | +# Node.js (via nvm) |
| 94 | +nvm install 18 |
| 95 | + |
| 96 | +# Rust |
| 97 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 98 | +``` |
| 99 | + |
| 100 | +## Adding New Tests |
| 101 | + |
| 102 | +To add a new test: |
| 103 | + |
| 104 | +1. Add a new test function in `smoke-test.sh` (e.g., `test_new_feature()`) |
| 105 | +2. Include dependency checks, builds, and test execution in the function |
| 106 | +3. Add a `run_test` call in the "Run all tests" section |
| 107 | +4. Update this README |
| 108 | + |
| 109 | +## Maintenance |
| 110 | + |
| 111 | +These tests are designed to be simple and low-maintenance: |
| 112 | + |
| 113 | +- Shell scripts for orchestration (language-agnostic) |
| 114 | +- Minimal TypeScript helpers for test infrastructure |
| 115 | +- No external API dependencies |
0 commit comments