-
Notifications
You must be signed in to change notification settings - Fork 172
feat: Add authentication to the endpoints #107
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
base: main
Are you sure you want to change the base?
Conversation
d09de51
to
0565b1f
Compare
0565b1f
to
72fa239
Compare
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #107 +/- ##
==========================================
+ Coverage 97.20% 97.42% +0.22%
==========================================
Files 6 8 +2
Lines 823 972 +149
Branches 30 36 +6
==========================================
+ Hits 800 947 +147
- Misses 15 16 +1
- Partials 8 9 +1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Hey @pablotp, nice contribution! Can you resolve failures in the build checks? |
Fixes sparfenyuk#95 This adds the option `--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}` to define the log level. If both `--debug` and `--log-level` are provided, the former takes precedence.
4f9c96a
to
2f8f658
Compare
@sparfenyuk I'm sorry for not looking more carefully into the pre-commits and test setup. I've just pushed a commit to address the issues and resolve the conflicts with |
@sparfenyuk it seems a file outside of my PR caused an error for the linter. I've pushed a new commit to address this: 218da4f Thanks for your prompt response! |
@pablotp Thank you, and no worries - all good! |
Add authentication support
Summary
Adds optional API key authentication to protect
/sse
and/mcp
endpoints. Authentication is disabled by default for backward compatibility.Changes
AuthMiddleware
class for API key validation--api-key
CLI argument andMCP_PROXY_API_KEY
environment variable support/sse
,/mcp
,/messages/*
(including named server paths)/status
, OPTIONS requestsUsage
Testing
Manual verification commands
Make sure you have installed dependencies:
Test 1: Server WITHOUT Authentication
Open Terminal 1 and start the server:
Open Terminal 2 and test endpoints:
Test 2: Server WITH Authentication (CLI argument)
Open Terminal 1 and start the server with API key:
Open Terminal 2 and test endpoints:
Test 3: Server WITH Authentication (Environment Variable)
Open Terminal 1 and start the server with env var:
Open Terminal 2 and test:
Test 4: Named Server Endpoints
Start server with named servers and authentication:
Test in another terminal:
Expected Results
Related