- Home
- MCP servers
- Traffic
Traffic
- typescript
0
GitHub Stars
typescript
Language
6 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You deploy and run a Traffic MCP Server that communicates with a traffic prediction REST API using SSE transport. It exposes tools to list traffic stations, predict speed performance, and suggest routes, making it easy to build responsive, cloud-ready traffic insights for your applications.
How to use
You interact with the MCP server through an MCP client by connecting to its SSE endpoint and using the provided tools. When you start the server, you obtain a secure channel (Authorization header with a Bearer token) to request station data, run predictions, and obtain route suggestions. Use the server’s health endpoint to verify it is running before making requests.
How to install
Prerequisites you need on your machine: Python 3.10 or higher and pip.
Install dependencies locally using the project configuration or install directly from the repository.
pip install mcp httpx starlette uvicorn[standard]
pip install -e .
Configuration and usage details
Two main connection methods exist: a remote HTTP/SSE endpoint and a local stdio run. The remote endpoint is accessed via SSE at a URL that ends with /sse and requires an API key for authentication. The local stdio option runs the server directly on your machine using a Python command.
{
"mcpServers": [
{
"type": "http",
"name": "traffic_http",
"url": "https://traffic-mcp-server-xxxxx.a.run.app/sse",
"args": []
},
{
"type": "stdio",
"name": "traffic_local",
"command": "python",
"args": ["server.py"],
"env": [
{"name": "MCP_API_KEY", "value": "YOUR_API_KEY"},
{"name": "TRAFFIC_API_URL", "value": "https://traffict-predict-api-452792205673.southamerica-west1.run.app"}
]
}
]
}
Security and access
Requests to the SSE endpoint require an Authorization header with a Bearer token. The token is validated against the MCP_API_KEY you configure in the environment. Unauthenticated connections receive a 401 error.
Endoints and tools
The server offers three primary MCP tools: get_traffic_stations, predict_traffic_spi, and suggest_routes. The server exposes an SSE endpoint for persistent MCP streams and a health check endpoint to monitor status.
Monitoring and health checks
Check the server health with the health endpoint. Ensure the server is running before issuing MCP tool requests.
Development and testing
For development, you can run the server with hot-reload support in a development environment if needed, and install development dependencies as described in the installation steps.
uvicorn server:app --reload --host 0.0.0.0 --port 8080
Deployment notes
Two common deployment approaches are running locally with stdio for development or deploying to a cloud service using a container image. When deploying, set environment variables MCP_API_KEY and TRAFFIC_API_URL to secure values.
# Docker example
docker build -t traffic-mcp-server .
# Run container with environment variables
docker run -p 8080:8080 \
-e MCP_API_KEY="YOUR_API_KEY" \
-e TRAFFIC_API_URL="https://traffict-predict-api-452792205673.southamerica-west1.run.app" \
traffic-mcp-server
Troubleshooting
If you encounter a 401 Unauthorized, verify that you pass the Authorization header with the correct Bearer token and that the token matches MCP_API_KEY. If the server cannot be reached, ensure the server is running and the URL is correct.
Notes and common references
When configuring clients like Claude Desktop, provide the SSE transport URL and an Authorization header with your API key to access the MCP server securely.
Appendix: Endpoints you will use
SSE endpoint for MCP connections: /sse Health check: /health
License
MIT license.
Support
Open issues with problems or feature requests as you develop and deploy your MCP server.
Available tools
get_traffic_stations
Retrieves the list of available traffic stations, with optional filters like freeway and direction.
predict_traffic_spi
Predicts the Speed Performance Index using an LSTM model based on historical data.
suggest_routes
Suggests optimal routes between two stations using Dijkstra’s algorithm.