🤖mcp server oauth - #2646
Open
AntoLC wants to merge 6 commits into
Open
Conversation
Contributor
|
Size Change: 0 B Total Size: 5.94 MB 📦 View Changed
|
We added a basic MCP API to the backend. This API is designed to facilitate integration with external systems, providing a secure and efficient way to access document data. API endpoints include: - POST /api/v1.0/mcp/documents/search -> search_documents - GET /api/v1.0/mcp/documents/<id> -> read_document - POST /api/v1.0/mcp/documents -> create_document
Add to the dev realm:
- `docs-mcp-client`, the public PKCE client MCP clients authenticate
with, with optional scopes `docs:documents:{search,read,create}` and
`docs-mcp`.
- `docs-api`, the confidential client Django uses as introspection
credentials (`OIDC_RS_CLIENT_ID/SECRET`).
- the `docs:documents:*` consent scopes and a `docs-mcp` audience-mapper
scope that stamps the `docs-mcp` audience only when requested.
Point the resource-server env at the `impress` realm and the new
clients, allow the `docs-mcp-client` audience, and grant users
`offline_access` for refresh tokens.
AntoLC
force-pushed
the
feat/mcp-server-oauth
branch
from
September 6, 2026 12:20
b7f3bec to
f978612
Compare
Add `src/frontend/servers/mcp`, a stateless TypeScript (Express + `@modelcontextprotocol/sdk`) MCP server exposing `search_documents`, `read_document` and `create_document` over Streamable HTTP. It is an OAuth resource server holding no credentials of its own: it verifies the caller's Keycloak token against the realm JWKS (`src/auth/jwtVerifier.ts`), checks the `docs-mcp` audience, then forwards the same token unchanged to Django's `/api/v1.0/mcp/documents/*` endpoints (`src/docsApiClient.ts`), which stays the sole authority on document permissions. No token exchange. Ship the `mcp-development` compose service, its `env.d/development/mcp` env file, a `build-mcp` Makefile helper, and `documentation/mcp_server.md` describing the full flow and how to connect MCP clients.
Add a `yarn mcp-inspector` script that launches `@modelcontextprotocol/inspector` against the local docs-mcp server, with a checked-in config pre-filling the URL and the `docs-mcp-client` OAuth client and scopes so there is nothing to type in by hand.
We added some helper commands to the Makefile to facilitate the development of the docs-mcp. These commands allow developers to easily connect to the docs-mcp server with your favorite LLM. You can start the MCP Inspector with `make mcp-inspector` to connect to the docs-mcp server and inspect the different endpoints and their responses.
Wire up the corresponding build-and-push-mcp jobs in the Docker Hub and GHCR workflows.
AntoLC
force-pushed
the
feat/mcp-server-oauth
branch
from
September 6, 2026 12:34
f978612 to
d6420cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR lays the groundwork for an MCP server for Docs (docs-mcp): a remote MCP server exposing three tools backed by the Django API:
It is an OAuth-protected resource server: MCP clients authenticate the user against Keycloak (Authorization Code + PKCE, public docs-mcp-client), and the server forwards that same access token, unchanged, to Django.
Django stays the sole authority on document permissions — ResourceServerAuthentication (django-lasuite) introspects the token on every call and the existing DocumentViewSet permissions/querysets decide access.
There is deliberately no RFC 8693 token exchange: the TypeScript server (Express + @modelcontextprotocol/sdk, stateless Streamable HTTP) holds no credentials of its own, only reading Keycloak's public JWKS to verify signatures.
We're eager to hear from people using it and to see it augmented — more tools, richer document operations, DCR, token exchange — so please try it and tell us what you need.
How to do
To start the mcp server, as usual:
make buildmake runWhen your MCP is running, you can check that everything is fine by checking it with mcp-inspector, by running:
make mcp-inspectordocs/Makefile
Lines 528 to 530 in b7f3bec
You can use it with your favorite LLM (Claude, Codex, Cursor...), here some helpers to plug it easily:
make mcp-claudemake mcp-codexMore here:
docs/Makefile
Lines 462 to 527 in b7f3bec
Extensive documentation here:
https://github.com/suitenumerique/docs/blob/feat/mcp-server-oauth/documentation/mcp_server.md