Skip to main content

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.

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, and tools/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
}

GET is not supported in stateless mode​

Return 405 Method not allowed. because stateless mode does not support the Streamable HTTP GET stream.

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
}

DELETE is not supported in stateless mode​

Return 405 Method not allowed. because stateless mode does not support session termination.

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
}

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 toolForwarded HTTP endpointUnderlying module
create_standard_vllm_deployment_runPOST /api/v1/deployments/standard-vllm-runsDeployments via llm_d_lens/deploy/router.py
list_deployment_executionsGET /api/v1/deployments/executionsDeployments via llm_d_lens/deploy/router.py
create_evaluate_runPOST /api/v1/evaluate/runsEvaluation via llm_d_lens/evaluation/router.py
get_cluster_stack_statusGET /api/v1/monitoring/cluster-stack/statusObservability via llm_d_lens/monitoring/cluster_stack/router.py
list_simulation_tasksGET /api/simulation/tasksSimulation 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).