Skip to content

The instructions for /agents/guides/remote-mcp-server with Auth and Auth are missing steps and/or out of date #22343

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

Open
jschlesser opened this issue May 12, 2025 · 1 comment
Assignees
Labels
product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously.

Comments

@jschlesser
Copy link

Regarding https://developers.cloudflare.com/agents/guides/remote-mcp-server/

Someone should walk through the instructions and update both the template and the instructions for the section for Authorization and Authentication.

The docs have the user install a template
npm create cloudflare@latest -- my-mcp-server-github-auth --template=cloudflare/ai/demos/remote-mcp-github-oauth

That template has a source file github-handler.cs that references an environment variable COOKIE_ENCRYPTION_KEY

Later in the docs there is a copyable set of terminal instructions to set up .dev.env, this should include the COOKIE_ENCRYPTION_KEY

The worker-configuration.d.ts file Env section needs changes as well, this worked for me:

declare namespace Cloudflare {
interface Env {
OAUTH_KV: KVNamespace;
GITHUB_CLIENT_ID: string;
GITHUB_CLIENT_SECRET: string;
COOKIE_ENCRYPTION_KEY: string;
MCP_OBJECT: DurableObjectNamespace<import("./src/index").MyMCP>;
AI: Ai;
}
}
interface Env extends Cloudflare.Env {}

The index file needed to be updated with the following for the export of OAuthProvider
export default new OAuthProvider({
apiRoute: "/sse",
apiHandlers: {
'/sse': MyMCP.serveSSE('/sse'),
'/mcp': MyMCP.serve('/mcp'),
},
defaultHandler: GitHubHandler,
authorizeEndpoint: "/authorize",
tokenEndpoint: "/token",
clientRegistrationEndpoint: "/register",
});

With all of those changes, I was able to get the MCP Inspector instructions to work.

@github-actions github-actions bot added the product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. label May 12, 2025
@MarceloEmmerich
Copy link

i tried both the outdated instructions and also these ones. I do get an initial 401, which seems correct since I am not authed yet, but then nothing happens. The redirect does not happen, neither locally nor depoyed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously.
Projects
None yet
Development

No branches or pull requests

7 participants