Add an MCP server for the API, deployable next to the application
mcp/ exposes both APIs as MCP tools, one per operation in openapi.yaml, named after the Laravel route each lands on (public_projects_index, admin_pages_update, ...). Nothing is written by hand: the tools are derived from the document the target application serves, which the contract tests already hold to the truth. Two transports over one core: - stdio (`node mcp/server.mjs`), registered in .mcp.json, signing in with credentials from the environment and refreshing the token. - Streamable HTTP (`--http`), stateless, deployed as the landing-mcp service. It holds no credentials: each request brings its caller's Pireon Basic credentials or bearer token, so the API applies that person's permissions. Sessions live in memory keyed by a hash, refused credentials are remembered for a minute, and the spec is reloaded every minute so new endpoints appear without a redeploy. Left out on purpose: the token exchange, telemetry, and the contact and apply forms, which notify real people. The preview secret is never sent for anonymous callers, and is unset in the deployment by default. A CI job runs the Node tests, including the HTTP mode end to end against a fake application. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
###############################################################################
|
||||
# Production stack.
|
||||
#
|
||||
# Four containers and one database. Deliberately no Redis: Postgres holds the
|
||||
# Five containers and one database. Deliberately no Redis: Postgres holds the
|
||||
# cache, the sessions and the queue, which for a site this size is plenty and
|
||||
# is one less thing to run, back up and forget to secure. Swapping it in later
|
||||
# is three environment variables.
|
||||
@@ -210,6 +210,45 @@ services:
|
||||
condition: service_healthy
|
||||
stop_grace_period: 30s
|
||||
|
||||
# The MCP server (mcp/), so Claude and other MCP clients can use the API
|
||||
# from anywhere, not only from a checkout of this repository. It reaches the
|
||||
# application over the stack's own network rather than the public domain:
|
||||
# one hop, no TLS, and it keeps working while the domain is misconfigured.
|
||||
#
|
||||
# Holds no credentials of its own. Every request brings its caller's Pireon
|
||||
# credentials, and the API applies that person's permissions — see the
|
||||
# README's "Servidor MCP" section for how to connect.
|
||||
#
|
||||
# Like `landing-app`, published only through `dokploy-network`: add its
|
||||
# domain in Dokploy's "Domains" tab, pointing at port 3000, and the endpoint
|
||||
# is https://<that domain>/mcp.
|
||||
landing-mcp:
|
||||
build:
|
||||
context: ./mcp
|
||||
image: landing-mcp:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
LANDING_URL: http://landing-app:8080
|
||||
LANDING_MCP_REQUIRE_AUTH: ${LANDING_MCP_REQUIRE_AUTH:-false}
|
||||
# Deliberately not SITE_PREVIEW_TOKEN by default: with it, anyone who can
|
||||
# sign in sees every draft through the public tools, whatever their role
|
||||
# would let them see in the panel. Set it to that value knowingly.
|
||||
LANDING_PREVIEW_TOKEN: ${LANDING_MCP_PREVIEW_TOKEN:-}
|
||||
expose:
|
||||
- "3000"
|
||||
networks:
|
||||
- dokploy-network
|
||||
- default
|
||||
depends_on:
|
||||
landing-app:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3000/up').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
start_period: 10s
|
||||
retries: 3
|
||||
|
||||
postgres:
|
||||
image: postgres:17-alpine
|
||||
restart: unless-stopped
|
||||
|
||||
Reference in New Issue
Block a user