chore: implementing the register and code exchange

Signed-off-by: benjdlambert <ben@blam.sh>

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-07-03 11:16:51 +02:00
parent 628322d19b
commit 0d142d95ec
4 changed files with 80 additions and 15 deletions
+26 -1
View File
@@ -42,8 +42,17 @@ export const mcpPlugin = createBackendPlugin({
httpRouter: coreServices.httpRouter,
actions: actionsServiceRef,
registry: actionsRegistryServiceRef,
rootRouter: coreServices.rootHttpRouter,
discovery: coreServices.discovery,
},
async init({ actions, logger, httpRouter, httpAuth }) {
async init({
actions,
logger,
httpRouter,
httpAuth,
rootRouter,
discovery,
}) {
const mcpService = await McpService.create({
actions,
});
@@ -66,6 +75,22 @@ export const mcpPlugin = createBackendPlugin({
router.use('/v1', streamableRouter);
httpRouter.use(router);
// todo(blam): there's probably a better way to proxy this, but it's required
// for mcp auth spec that it lives on the root of the mcp entrypoint server.
const authRouter = Router();
authRouter.use('/', async (_, res) => {
const authBaseUrl = await discovery.getBaseUrl('auth');
const oidcResponse = await fetch(
`${authBaseUrl}/.well-known/openid-configuration`,
);
const oidcResponseJson = await oidcResponse.json();
res.json(oidcResponseJson);
});
rootRouter.use('/.well-known/oauth-authorization-server', authRouter);
},
});
},