Testing MCP servers over HTTP transports (HTTP streaming and SSE).
MCP-Jest supports three transport types:
| Transport | Description | Use Case |
|---|---|---|
stdio |
Standard input/output | Local servers (default) |
streamable-http |
HTTP streaming | Remote HTTP servers |
sse |
Server-Sent Events | Real-time streaming servers |
# CLI
mcp-jest --transport streamable-http --url http://localhost:3000/mcp --tools search
# With config file
mcp-jest --config http-test.json{
"server": {
"transport": "streamable-http",
"url": "http://localhost:3000/mcp"
},
"tests": {
"tools": {
"search": {
"args": { "query": "test" },
"expect": "content.length > 0"
}
},
"timeout": 60000
}
}import { mcpTest } from 'mcp-jest';
const results = await mcpTest(
{
transport: 'streamable-http',
url: 'http://localhost:3000/mcp'
},
{
tools: {
search: {
args: { query: 'test' },
expect: 'content.length > 0'
}
},
timeout: 60000
}
);# CLI
mcp-jest --transport sse --url http://localhost:3000/sse --tools search
# With timeout
mcp-jest --transport sse --url http://localhost:3000/sse --tools search --timeout 60000{
"server": {
"transport": "sse",
"url": "http://localhost:3000/sse"
},
"tests": {
"tools": ["search", "stream"],
"timeout": 60000
}
}import { mcpTest } from 'mcp-jest';
const results = await mcpTest(
{
transport: 'sse',
url: 'http://localhost:3000/sse'
},
{
tools: ['search', 'stream'],
timeout: 60000
}
);# Test a deployed MCP server
mcp-jest --transport streamable-http \
--url https://api.example.com/mcp \
--tools "search,calculate" \
--timeout 30000# Start your HTTP server first
node ./http-server.js &
# Then test it
mcp-jest --transport streamable-http \
--url http://localhost:3000/mcp \
--tools search{
"server": {
"transport": "streamable-http",
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer test-token"
}
},
"tests": {
"tools": {
"search": {
"args": { "query": "test query" },
"expect": "content[0].text.length > 0"
},
"calculate": {
"args": { "expression": "2 + 2" },
"expect": "content[0].text === '4'"
}
},
"resources": {
"config": { "expect": "exists" }
},
"timeout": 60000
}
}# .github/workflows/http-test.yml
name: HTTP MCP Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- name: Start HTTP Server
run: |
node ./dist/http-server.js &
sleep 5 # Wait for server startup
- name: Test MCP Server
run: |
npm install -g mcp-jest
mcp-jest --transport streamable-http \
--url http://localhost:3000/mcp \
--tools "search,calculate" \
--timeout 60000# Dockerfile.test
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
RUN npm install -g mcp-jest
# Start server and run tests
CMD sh -c "node dist/http-server.js & sleep 5 && mcp-jest --transport streamable-http --url http://localhost:3000/mcp --tools search"| Feature | stdio | HTTP (streamable-http/SSE) |
|---|---|---|
| Setup | Simple | Requires running server |
| Local testing | Best choice | Works |
| Remote testing | Not possible | Best choice |
| CI/CD | Simple | Need to start server |
| Performance | Fastest | Network overhead |
| Debugging | Easy | Check server logs |
- Testing locally during development
- Server is a CLI application
- Simple CI/CD setup
- Best performance is needed
- Testing remote servers
- Server is an HTTP API
- Testing deployed services
- Testing microservices
- Server uses Server-Sent Events
- Real-time streaming responses
- Long-running operations
# Check server is running
curl http://localhost:3000/health
# Check correct port
netstat -an | grep 3000
# Check URL format
mcp-jest --transport streamable-http --url http://localhost:3000/mcp # Include path# Increase timeout for slow servers
mcp-jest --transport streamable-http \
--url http://localhost:3000/mcp \
--tools search \
--timeout 120000If testing from a browser environment, ensure your server has proper CORS headers:
// Server-side
app.use(cors({
origin: '*',
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization']
}));# For self-signed certificates in development
NODE_TLS_REJECT_UNAUTHORIZED=0 mcp-jest --transport streamable-http \
--url https://localhost:3000/mcp \
--tools search{
"server": {
"transport": "streamable-http",
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer your-token",
"X-API-Key": "your-api-key"
}
}
}# Discover capabilities of HTTP server
mcp-jest discover --transport streamable-http --url http://localhost:3000/mcp
# Save as config
mcp-jest discover --transport streamable-http \
--url http://localhost:3000/mcp \
--output http-tests.json# Validate HTTP server compliance
mcp-jest validate --transport streamable-http \
--url http://localhost:3000/mcp \
--depth full \
--output compliance.json- CLI Reference - All CLI options
- GitHub Actions - CI/CD integration
- Troubleshooting - Common issues
- Architecture - How transports work