Overview
Let’s send your first message to the MCP Server with LangGraph! This guide walks you through authentication, making a request, and understanding the response.Before you start: Make sure you’ve completed the Quick Start and have the services running.
Prerequisites
Verify services are running:All services healthy? Let’s make your first request!
Step-by-Step Tutorial
1
Get an Authentication Token
- Python
- cURL
- JavaScript
In production, obtain tokens through proper authentication flows (Keycloak OAuth2, etc.). See Authentication Guide.
2
Send Your First Message
- Python
- cURL
- JavaScript
3
Understanding the Response
The agent returns a structured JSON response:
string
The agent’s response text
string
Always
"assistant" for agent responsesstring
LLM model used (supports fallback to alternative models)
object
Token usage statistics:
prompt_tokens: Input tokenscompletion_tokens: Output tokenstotal_tokens: Sum of both
string
OpenTelemetry trace ID for debugging. View in Jaeger UI.
boolean
Whether user was authorized (OpenFGA check passed)
4
View Trace in Jaeger
Every request is traced end-to-end:
- Open Jaeger UI: http://localhost:16686
- Select service:
mcp-server-langgraph - Click “Find Traces”
- Click on your trace to see:
- Request flow
- LLM call with prompt
- Authorization check
- Response generation
- Timing breakdown
View distributed traces in the Jaeger UI at http://localhost:16686 to see the full request flow.
Complete Example
Here’s a full working example:Common Use Cases
Simple Q&A
Multi-Turn Conversation
Tool Usage
Streaming Responses
Error Handling
Authentication Errors
Authorization Errors
Rate Limiting
Server Errors
Best Practices
Handle Errors Gracefully
Handle Errors Gracefully
Set Timeouts
Set Timeouts
Track Token Usage
Track Token Usage
Use Trace IDs for Debugging
Use Trace IDs for Debugging
Testing Your Integration
Unit Tests
Integration Tests
Next Steps
Authentication
Learn about JWT and Keycloak authentication
Authorization
Configure fine-grained permissions
API Reference
Explore all API endpoints
Multi-LLM Setup
Configure multiple LLM providers
Congratulations! You’ve sent your first request to the MCP agent. Ready to build something amazing?