-
Notifications
You must be signed in to change notification settings - Fork 553
Add Auth debugger tab #355
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
Conversation
Hey @pcarleton , I'm also working on something similar. Want to sync on discord? Maybe I can help with something. I'm using Postman since the inspector can't handle it but I was interested in what specific oauth flow you're following. Have you noticed that the specification was updated in draft a few days ago? |
Hi @QuantGeekDev which discord? Yes, with the new draft, we'll need to add a few more metadata endpoints to check, but that should be okay to just follow what the Typescript SDK does. I'm going to try to land this on the 2025-03-25 spec and update it from there. |
@pcarleton The modelcontextprotocol one: https://discord.gg/3uqNS3KRP2 |
it's testable against the python example server here: Also can test against some of the public servers e.g. |
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.
LGTM
- Breaking down into components would be good before merging
- maybe make it explicit that only sse will work for now
- add small banner to say which spec auth is supporing
client/src/App.tsx
Outdated
const AuthDebuggerWrapper = () => ( | ||
<TabsContent value="auth"> | ||
<AuthDebugger | ||
sseUrl={sseUrl} |
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.
something for the follow up (for myself) - we need to support shttp as well
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.
true, I think it should be pretty much the same because this all happens before any MCP protocol initialization.
I've been testing this on the python simple auth server, do we have a streamable http auth example? can modify the existing one to add it if not
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.
yeah, it should be something like this: modelcontextprotocol/python-sdk#695 will test and publish the PR
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.
great, this seems to work.
One thing I didn't fully go through and update is the state parameter in App.tsx, it's still called sseUrl
even though it can be either sse or streambleHttp. won't tackle that here, but wanted to mention while it's fresh.
latestError: null, | ||
}); | ||
|
||
if (authState.oauthStep === "not_started") { |
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.
pattern matching would be nice (something like a state machine) to have here instead of if-else
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.
👍 I pulled this out into a state machine... the if/else was getting unwieldy, and also made retrying steps annoying
const provider = new DebugInspectorOAuthClientProvider(sseUrl); | ||
|
||
// Helper functions moved inside useCallback to avoid ESLint warning | ||
const validateOAuthMetadata = async ( |
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.
validateOAuthMetadata
and validateClientInformation
can be extracted:
- avoid recreation on every render
- clean up
proceedToNextStep
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.
👍 addressed w/ state machine
); | ||
}, [authState.statusMessage]); | ||
|
||
const renderOAuthFlow = useCallback(() => { |
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.
maybe break it down into components? Like OAuthStepItem
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.
yea good call, I broke out the Progress flow component, and a smaller component for each step lmkwyt
Hi Paul, I started testing with this today to see if it would play nice with my E2E Playwright testing branch, and noticed that the branch is quite a few commits behind main. Since I think there were a few auth related commits since you added this, could you pull the latest from main to verify its still working as expected? (And I'm doing the same with my own testing.) |
ty @olaservo, I was missing the scope auth change (forgot I had hacked it in locally). I've updated the typescript sdk import so that the types for the A few things still to go:
|
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.
LGTM!
Should we do follow ups as part of a separate PR and merge this one?
yea this is getting pretty large, will fix w/ follow-ups. |
@pcarleton question for you, I feel like I'm missing something: why the That's not standard AFAICT, why not just reuse |
Also the authorization URL generated by the debugger isn't the same as the "connect" button. It includes the I feel like the Connect button also should do that though? Spec isn't exactly prescriptive but the inspector is meant for debugging. 🤔 edit: I'll open a PR actually. |
@leblancfg this was to allow for a different handler when debugging vs. when doing the normal "connect" flow. When you do the step-by-step flow, we show the token and suggest you copy-paste it. We don't want to do that in the normal flow. |
Motivation and Context
Adds a step-by-step auth debugger, going through the different client steps for a server.
How Has This Been Tested?
I've tested this locally against the python example auth SSE server:
modelcontextprotocol/python-sdk#610
I also tested against:
Breaking Changes
none
Types of changes
Checklist
Additional context