Repository navigation
adds features to implement MCP server responsibilities in agentgateway - #212
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds features to implement MCP client responsibilities in agentgateway by enhancing the UI's handling of optional array properties and adding MCP authentication capabilities with OAuth support.
- Adds null-safe array iteration throughout the UI to prevent runtime errors when backend arrays are undefined
- Implements OAuth 2.0 protected resource metadata support for MCP authentication flows
- Adds comprehensive MCP authentication example with authorization server and configuration files
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/lib/backend-hooks.ts | Added null-safe array iteration for backends |
| ui/src/lib/api.ts | Added null-safe forEach calls for backend arrays |
| ui/src/components/setup-wizard/PolicyStep.tsx | Improved code formatting for JWKS URL detection |
| ui/src/components/route/route-components.tsx | Enhanced string literal consistency and formatting |
| ui/src/components/policy/form-renderers.tsx | Improved text formatting for A2A policy descriptions |
| ui/src/components/policy-config.tsx | Enhanced filtering logic formatting |
| ui/src/components/forms/jwt-config-form.tsx | Improved conditional formatting for JWKS configuration |
| ui/src/components/backend-config.tsx | Enhanced button formatting |
| ui/src/app/policies/page.tsx | Improved conditional logic formatting |
| ui/src/app/playground/page.tsx | Enhanced error handling, string formatting, and import organization |
| ui/src/app/backends/page.tsx | Added null-safe forEach for backend iteration |
| examples/mcp-authentication/config.yaml | Added comprehensive MCP authentication configuration |
| examples/mcp-authentication/config-remote-endpoints.yaml | Added remote endpoint authentication configuration |
| examples/mcp-authentication/auth_server.py | Added complete OAuth 2.0 authorization server implementation |
| examples/mcp-authentication/README.md | Added documentation for MCP authentication setup |
| examples/http/config.yaml | Minor formatting change to response body |
| crates/agentgateway/src/types/local.rs | Added OAuth protected resource filter support |
| crates/agentgateway/src/types/agent.rs | Added custom IDP support and OAuth resource filter |
| crates/agentgateway/src/proxy/httpproxy.rs | Integrated OAuth protected resource filter processing |
| crates/agentgateway/src/mcp/sse.rs | Enhanced MCP authentication with proper response handling |
| crates/agentgateway/src/http/oauth_protected_resource.rs | Added OAuth 2.0 resource metadata implementation |
| crates/agentgateway/src/http/mod.rs | Added OAuth protected resource module |
| crates/agentgateway/src/http/jwt.rs | Added required JWT validation method |
3ccfde7 to
ee1fc83
Compare
f1d02b4 to
a21b891
Compare
|
addressed the conflict and the test failures |
| } | ||
|
|
||
| async fn protected_resource_metadata(&self, req: Request, auth: McpAuthentication) -> Response { | ||
| let new_uri = Self::get_redirect_url(&req, "/.well-known/oauth-protected-resource"); |
There was a problem hiding this comment.
It looks like /.well-known/oauth-protected-resource is not a suffix (line 311), but a prefix in URL Path. So it ends up with errors like this http://localhost:3003/.well-known/oauth-protected-resource/mcp -> http://localhost:3003/.well-known/oauth-protected-resource/mcp/mcp in MCP Inspector.
|
I hacked a quick prototype for MCP protected resource metadata with AgentGateway's DirectResponse and Cors, but this approach looks more promising. |
|
@amivanoff I initially started with a separate field, but I was unsure and decided to merge it and gather feedback during PR review. I discovered that I need some changes before we merge this PR I'll try to get back to this before the end of the week. Tests would be greatly appreciated! |
|
I merged this PR with the latest main and cleared a bit examples (README.md and config.yaml), code and JSON schema to make them consistent and the overall policy a little more configurable and ready for further testing. In JSON schema and Yaml:
Not touched:
All resides in a branch in my fork. I could contribute it here if needed and if allowed in permissions. |
5bd5b29 to
444eac7
Compare
|
@amivanoff we are discussing how the API for this should look, but it can end up being very similar to what you have on your branch. As soon as we agree on the API, we should have the code merged fairly quickly. |
|
@rinormaloku regarding the API, it would be great to have ability to customize config or to use reasonable defaults as a fallback of some sort. For example, admin could provide custom For example in our current setup |
444eac7 to
f729cc7
Compare
…er responsibilities
ffae45c to
d280189
Compare
- Updated `heck` dependency to version 0.5.0 in `Cargo.lock` and `Cargo.toml`. - Refactored `ResourceMetadata` to use a flexible structure with additional properties. - Simplified JSON construction for resource metadata in the MCP server. - Removed deprecated fields from the schema and updated documentation accordingly.
- Renamed `run-validate-deps` to `run-validation-deps` for consistency. - Updated corresponding commands in the `examples/mcp-authentication/README.md` to reflect the new target names.
|
Got around to cleaning this up. It is ready for review! |
| .header("access-control-allow-origin", "*") | ||
| .header("access-control-allow-methods", "GET, OPTIONS") | ||
| .header("access-control-allow-headers", "content-type") |
There was a problem hiding this comment.
This is a little suspicious. Shouldn't the CORS filter handle this? I believe these apply even with the MCP path
| .header("access-control-allow-methods", "GET, OPTIONS") | ||
| .header("access-control-allow-headers", "content-type") | ||
| .body(axum::body::Body::from(Bytes::from( | ||
| serde_json::to_string(&json_body).unwrap_or_default(), |
There was a problem hiding this comment.
nit: we should probably make to_string() failing return a INTERNAL_SERVER_ERROR vs the .body() call which cannot actually fail (only fails from invalid headers, and the headers are static)
| let mut upstream = client.simple_call(ureq).await?; | ||
|
|
||
| // Add CORS headers to the response | ||
| let headers = upstream.headers_mut(); |
| // of fields we compute. | ||
| for (key, value) in &self.extra { | ||
| let snake = key.to_snake_case(); | ||
| if snake == "resource" || snake == "authorization_servers" { |
There was a problem hiding this comment.
we add 2 other ones too. But it doesn't matter since we override them?
agentgateway#212) * adds support for resource server metadata endpoint and other MCP server responsibilities * Update dependencies and enhance resource metadata handling - Updated `heck` dependency to version 0.5.0 in `Cargo.lock` and `Cargo.toml`. - Refactored `ResourceMetadata` to use a flexible structure with additional properties. - Simplified JSON construction for resource metadata in the MCP server. - Removed deprecated fields from the schema and updated documentation accordingly. * Refactor Makefile targets for validation dependencies - Renamed `run-validate-deps` to `run-validation-deps` for consistency. - Updated corresponding commands in the `examples/mcp-authentication/README.md` to reflect the new target names.
This PR adds the options to configure MCP Server responsibilities in the agentgateway.
Additionally, it adds a test authorization server to try out the flows
See the example under
examples/mcp-authentication/README.mdfor quickly testing out the changes.