Skip to content

Commit cff3ecd

Browse files
committed
implementation of the mcp-auth endpoint
1 parent 1a12376 commit cff3ecd

File tree

17 files changed

+1271
-4
lines changed

17 files changed

+1271
-4
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ mcp_servers:
390390
Authorization: "kubernetes" # Uses user's k8s token from request auth
391391
```
392392

393-
The user's Kubernetes token is extracted from the incoming request's `Authorization` header and forwarded to the MCP server.
393+
**Note:** Kubernetes token-based MCP authorization only works when Lightspeed Core Stack is configured with Kubernetes authentication (`authentication.k8s`). For any other authentication types, MCP servers configured with `Authorization: "kubernetes"` are removed from the available MCP servers list.
394394

395395
##### 3. Client-Provided Tokens (For Per-User Authentication)
396396

@@ -418,6 +418,34 @@ curl -X POST "http://localhost:8080/v1/query" \
418418

419419
**Structure**: `MCP-HEADERS: {"<server-name>": {"<header-name>": "<header-value>", ...}, ...}`
420420

421+
##### Client-Authenticated MCP Servers Discovery
422+
423+
To help clients determine which MCP servers require client-provided tokens, use the **MCP Client Auth Options** endpoint:
424+
425+
```bash
426+
GET /v1/mcp-auth/client-options
427+
```
428+
429+
**Response:**
430+
```json
431+
{
432+
"servers": [
433+
{
434+
"name": "user-specific-service",
435+
"client_auth_headers": ["Authorization", "X-User-Token"]
436+
},
437+
{
438+
"name": "github-integration",
439+
"client_auth_headers": ["Authorization"]
440+
}
441+
]
442+
}
443+
```
444+
445+
This endpoint returns only MCP servers configured with `authorization_headers: "client"`, along with the specific header names that need to be provided via `MCP-HEADERS`. Servers using file-based or Kubernetes authentication are not included in this response.
446+
447+
**Use case:** Clients can call this endpoint at startup or before making requests to discover which servers they can authenticate with using their own tokens.
448+
421449
##### Combining Authentication Methods
422450

423451
You can mix and match authentication methods across different MCP servers, and even combine multiple methods for a single server:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
# Install curl for health checks
6+
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
7+
8+
# Copy the mock server script
9+
COPY dev-tools/mcp-mock-server/server.py .
10+
11+
# Expose HTTP port (we'll only use HTTP in Docker for simplicity)
12+
EXPOSE 3000
13+
14+
# Run the mock server (HTTP only on port 3000)
15+
CMD ["python", "server.py", "3000"]

docker-compose-library.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
services:
2+
# Mock MCP server for testing
3+
mcp-mock-server:
4+
build:
5+
context: .
6+
dockerfile: dev-tools/mcp-mock-server/Dockerfile
7+
container_name: mcp-mock-server
8+
ports:
9+
- "3000:3000"
10+
networks:
11+
- lightspeednet
12+
healthcheck:
13+
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
14+
interval: 5s
15+
timeout: 3s
16+
retries: 3
17+
start_period: 5s
18+
219
# Lightspeed Stack with embedded llama-stack (library mode)
320
lightspeed-stack:
421
build:
@@ -8,6 +25,11 @@ services:
825
container_name: lightspeed-stack
926
ports:
1027
- "8080:8080"
28+
depends_on:
29+
mcp-mock-server:
30+
condition: service_healthy
31+
networks:
32+
- lightspeednet
1133
volumes:
1234
# Mount both config files - lightspeed-stack.yaml should have library mode enabled
1335
- ./lightspeed-stack.yaml:/app-root/lightspeed-stack.yaml:Z
@@ -51,3 +73,6 @@ services:
5173
retries: 3 # how many times to retry before marking as unhealthy
5274
start_period: 15s # time to wait before starting checks (increased for library initialization)
5375

76+
networks:
77+
lightspeednet:
78+
driver: bridge

docker-compose.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
services:
2+
# Mock MCP server for testing
3+
mcp-mock-server:
4+
build:
5+
context: .
6+
dockerfile: dev-tools/mcp-mock-server/Dockerfile
7+
container_name: mcp-mock-server
8+
ports:
9+
- "3000:3000"
10+
networks:
11+
- lightspeednet
12+
healthcheck:
13+
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
14+
interval: 5s
15+
timeout: 3s
16+
retries: 3
17+
start_period: 5s
18+
219
# Red Hat llama-stack distribution with FAISS
320
llama-stack:
421
build:
@@ -69,6 +86,8 @@ services:
6986
depends_on:
7087
llama-stack:
7188
condition: service_healthy
89+
mcp-mock-server:
90+
condition: service_healthy
7291
networks:
7392
- lightspeednet
7493
healthcheck:

0 commit comments

Comments
 (0)