Lens Assistant
Backend API
Lens Assistant is backed by the Node MCP server under server/mcp/, not by a dedicated FastAPI router. server/server.js mounts mcpRouter directly with app.use(mcpRouter), and server/mcp/router.ts exposes the stateless Streamable HTTP endpoint at /api/mcp.
Send one stateless MCP request
Handle one stateless Streamable HTTP MCP request by creating a fresh McpServer, connecting it, and serving the request body.
- REST API
- Python API
POST /api/mcp
Request:
- Content type:
application/json - Body: one MCP JSON-RPC request object. In stateless mode, Lens creates a fresh server per request, so no session id is required.
- Common request shapes include
initialize,tools/list, andtools/call.
Example tools/call request:
{
"jsonrpc": "2.0",
"id": "req-2",
"method": "tools/call",
"params": {
"name": "list_simulation_backends",
"arguments": {}
}
}
Response:
Successful responses use MCP JSON-RPC result envelopes. For tool calls, Lens' MCP server returns content blocks whose text contains the JSON-stringified Lens REST result.
{
"jsonrpc": "2.0",
"id": "req-2",
"result": {
"content": [
{
"type": "text",
"text": "{\n \"items\": []\n}"
}
]
}
}
If an unhandled server error occurs before the SDK sends a response, Lens returns:
{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "Internal server error"
},
"id": null
}
This endpoint is a Node.js MCP handler, not a Python function — there is no direct Python call for the /api/mcp transport itself. Call the underlying Python-backed domain directly instead; for example, a deployment-related MCP tool can reuse the same deployment helper shown on the Deployments page:
from llm_d_lens.deploy.standard_kubernetes_service import (
StandardKubernetesServiceRequest,
build_standard_kubernetes_service_configuration,
)
request = StandardKubernetesServiceRequest(
model="meta-llama/Llama-3.1-8B-Instruct",
deployment_name="assistant-backed-deploy",
cluster_session_id="123e4567-e89b-12d3-a456-426614174000",
replicas=1,
tensor_parallel_size=1,
)
configuration = build_standard_kubernetes_service_configuration(request)
print(configuration.checksum)
GET is not supported in stateless mode
Return 405 Method not allowed. because stateless mode does not support the Streamable HTTP GET stream.
- REST API
- Python API
GET /api/mcp
Request:
This endpoint has no request body. In Lens' stateless MCP mode, the Streamable HTTP GET stream is intentionally disabled.
Response:
Returns a JSON-RPC error payload with HTTP status 405.
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Method not allowed."
},
"id": null
}
This endpoint is a Node.js MCP transport guard, not a Python function — there is no direct Python call. Use the underlying Python-backed module for the tool you actually want to invoke, as summarized below in What the MCP tools call.
DELETE is not supported in stateless mode
Return 405 Method not allowed. because stateless mode does not support session termination.
- REST API
- Python API
DELETE /api/mcp
Request:
This endpoint has no request body. Lens does not keep MCP sessions between requests, so there is no server-side session to terminate.
Response:
Returns a JSON-RPC error payload with HTTP status 405.
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Method not allowed."
},
"id": null
}
This endpoint is a Node.js MCP transport guard, not a Python function — there is no direct Python call. For Python automation, skip MCP and call the underlying Lens domain module directly.
The tool catalog is assembled in two parts: server/mcp/tools.ts contains 138 generated tools, and server/mcp/specialTools.ts contains 25 hand-written tools. The generated half is produced by node scripts/generate-mcp-tools.mjs from the llm_d_lens FastAPI OpenAPI schema, while the hand-written half covers composite or Node-backed routes. The handlers are thin wrappers over Lens' own REST API: server/mcp/internal.ts forwards requests to loopback /api/... paths through internalRequest(...).
What the MCP tools call
Representative generated MCP tools forward straight into existing Python-backed REST modules:
| MCP tool | Forwarded HTTP endpoint | Underlying module |
|---|---|---|
create_standard_vllm_deployment_run | POST /api/v1/deployments/standard-vllm-runs | Deployments via llm_d_lens/deploy/router.py |
list_deployment_executions | GET /api/v1/deployments/executions | Deployments via llm_d_lens/deploy/router.py |
create_evaluate_run | POST /api/v1/evaluate/runs | Evaluation via llm_d_lens/evaluation/router.py |
get_cluster_stack_status | GET /api/v1/monitoring/cluster-stack/status | Observability via llm_d_lens/monitoring/cluster_stack/router.py |
list_simulation_tasks | GET /api/simulation/tasks | Simulation via llm_d_lens/simulation/router.py |
If you need Python rather than MCP transport, call the underlying Python domains directly instead of /api/mcp. For example, the MCP tool create_standard_vllm_deployment_run ultimately reaches the same deployment helper used by POST /api/v1/deployments/standard-vllm-runs:
from llm_d_lens.deploy.standard_kubernetes_service import (
StandardKubernetesServiceRequest,
build_standard_kubernetes_service_configuration,
)
request = StandardKubernetesServiceRequest(
model="meta-llama/Llama-3.1-8B-Instruct",
deployment_name="assistant-backed-deploy",
cluster_session_id="123e4567-e89b-12d3-a456-426614174000",
replicas=1,
tensor_parallel_size=1,
)
configuration = build_standard_kubernetes_service_configuration(request)
print(configuration.checksum)
See the full request/response schemas in the FastAPI OpenAPI schema (regenerate with npm run docs:api).