-
Notifications
You must be signed in to change notification settings - Fork 70
fixing MCP headers usag for Llama stack 0.4.x, adding additional e2e tests for mcp servers #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Lightspeed Core Service - MCP Mock Server Test (Noop Auth) | ||
| service: | ||
| host: localhost | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| use_as_library_client: true | ||
| library_client_config_path: "dev-tools/test-configs/llama-stack-mcp-test.yaml" | ||
| user_data_collection: | ||
| feedback_enabled: false | ||
| transcripts_enabled: false | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_model: "gpt-4o-mini" | ||
| default_provider: "openai" | ||
| mcp_servers: | ||
| # Test 1: Static file-based authentication (HTTP) | ||
| - name: "mock-file-auth" | ||
| provider_id: "model-context-protocol" | ||
| url: "http://localhost:9000" | ||
| authorization_headers: | ||
| Authorization: "/tmp/lightspeed-mcp-test-token" | ||
| # Test 2: Kubernetes token forwarding (HTTP) | ||
| - name: "mock-k8s-auth" | ||
| provider_id: "model-context-protocol" | ||
| url: "http://localhost:9000" | ||
| authorization_headers: | ||
| Authorization: "kubernetes" | ||
| # Test 3: Client-provided token (HTTP - simplified for testing) | ||
| - name: "mock-client-auth" | ||
| provider_id: "model-context-protocol" | ||
| url: "http://localhost:9000" | ||
| authorization_headers: | ||
| Authorization: "client" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ services: | |||||||||||||||||||||||
| dockerfile: dev-tools/mcp-mock-server/Dockerfile | ||||||||||||||||||||||||
| container_name: mcp-mock-server | ||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||
| - "3000:3000" | ||||||||||||||||||||||||
| - "9000:3000" | ||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||
| - lightspeednet | ||||||||||||||||||||||||
| healthcheck: | ||||||||||||||||||||||||
|
|
@@ -84,6 +84,11 @@ services: | |||||||||||||||||||||||
| - TENANT_ID=${TENANT_ID:-} | ||||||||||||||||||||||||
| - CLIENT_ID=${CLIENT_ID:-} | ||||||||||||||||||||||||
| - CLIENT_SECRET=${CLIENT_SECRET:-} | ||||||||||||||||||||||||
| entrypoint: > | ||||||||||||||||||||||||
| /bin/bash -c " | ||||||||||||||||||||||||
| printf %s 'test-secret-token-123' > /tmp/lightspeed-mcp-test-token && | ||||||||||||||||||||||||
| /app-root/.venv/bin/python3.12 /app-root/src/lightspeed_stack.py | ||||||||||||||||||||||||
| " | ||||||||||||||||||||||||
|
Comment on lines
+87
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n docker-compose.yaml | sed -n '85,95p'Repository: lightspeed-core/lightspeed-stack Length of output: 519 🌐 Web query:
💡 Result: When you run a shell script as the container “main process”,
What to do instead (common fixes)
Sources: 🌐 Web query:
💡 Result:
Sources: Use Bash as PID 1 in containers won't forward 🛠️ Proposed fix- entrypoint: >
- /bin/bash -c "
- printf %s 'test-secret-token-123' > /tmp/lightspeed-mcp-test-token &&
- /app-root/.venv/bin/python3.12 /app-root/src/lightspeed_stack.py
- "
+ entrypoint: >
+ /bin/bash -c "
+ umask 077
+ printf %s 'test-secret-token-123' > /tmp/lightspeed-mcp-test-token &&
+ exec /app-root/.venv/bin/python3.12 /app-root/src/lightspeed_stack.py
+ "📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||||
| llama-stack: | ||||||||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: lightspeed-core/lightspeed-stack
Length of output: 127
🏁 Script executed:
sed -n '60,80p' ./docker-compose-library.yamlRepository: lightspeed-core/lightspeed-stack
Length of output: 1078
🌐 Web query:
bash PID1 signal handling Docker entrypoint💡 Result:
When your Docker container’s PID 1 is
bash(or/bin/sh -c), signal handling often surprises you:SIGTERM/SIGINT) won’t have their normal “default action” of terminating the process. Sodocker stopmay hang until Docker sendsSIGKILL. [1]CMD/ENTRYPOINT(string form), Docker effectively runs your command under/bin/sh -c, and signals may not reach your real app (your app isn’t PID 1). Docker explicitly warns that shell-formENTRYPOINT“does not pass signals”. [2]Best practices for Docker entrypoints
ENTRYPOINT/CMD(JSON array)This avoids
/bin/sh -cwrappers and lets your app receive signals directly. [2]execthe long-running processThis replaces the shell with your app, so the app becomes PID 1 and receives
SIGTERM. Docker’s own docs call out usingexecfor cleandocker stopbehavior. [2]--init(tini) or bake it indocker run --init …makes an init process run as PID 1 (backed by tini) and handle duties like signal forwarding and zombie reaping. [3]ENTRYPOINT ["tini","--","/your/entrypoint.sh"](tini docs). [4]Most common fix: switch to exec-form + ensure your entrypoint script ends with
exec …, or run with--init.Sources:
[1] Docker run reference (PID 1 signal behavior) https://www.docs4dev.com/docs/docker/19.03/engine/reference/run/
[2] Dockerfile reference (shell vs exec form; shell form doesn’t pass signals; use
exec) https://docs.docker.com/reference/builder[3]
docker container rundocs (--init, docker-init backed by tini) https://docs.docker.com/reference/cli/docker/container/run[4] tini README (
--initand usage) https://github.com/krallin/tini🌐 Web query:
umask 077 file permissions /tmp default permissions bash💡 Result:
umask 077affects new files/directories your process creates anywhere, including under/tmp. It removes all group/other permissions from the requested mode. (sans.org)0666 & ~0077 = 0600(rw-------)0777 & ~0077 = 0700(rwx------) (sans.org)/tmpitself is normally world-writable with the sticky bit: mode1777(drwxrwxrwt). Yourumaskdoes not change/tmp’s existing permissions; it only affects what you create inside it. (linuxconfig.org)Bash is not special here: if you set
umask 077in your shell (or in~/.bashrc, etc.), then commands you run from that shell inherit it and will create/tmpfiles accordingly (unless the program explicitlychmods after creation or requests a more restrictive mode). (bs2manuals.ts.fujitsu.com)Many systems ensure
/tmphas mode1777at boot via systemd-tmpfiles rules (example entries show1777directories under/tmp). (freedesktop.org)Citations:
🌐 Web query:
docker-compose entrypoint exec umask syntax YAML multiline string💡 Result:
Use exec-form (
entrypoint:as a YAML list) and run a shell explicitly so you can setumaskand thenexecthe real process (so it becomes PID 1 and receives signals). Compose allowsentrypointas either a string or a list; the list form is the “Dockerfile-like”/exec style. [1]Notes:
|is just YAML “multiline string”; it becomes the single script argument tosh -c(newlines included).--is used as the$0placeholder forsh -c; thencommand:becomes$@, whichexec "$@"runs.exec ...ensures the final process is PID 1 (important for signal handling), as recommended in Docker’s ENTRYPOINT docs. [2]Sources: Docker Compose
entrypointreference [1]; Docker ENTRYPOINT shell vs exec form +execfor proper PID 1 behavior [2].[1] (docs.docker.com)
[2] (docs.docker.com)
Citations:
Use
execand tighten token file permissions in the entrypoint.Bash as PID1 prevents proper signal forwarding—
docker stopmay hang untilSIGKILL. The token file in/tmpdefaults to world-readable mode. Addumask 077andexecthe Python process to make it PID1 and restrict the token file to owner-only (0600).🛠️ Proposed fix
🤖 Prompt for AI Agents