authoravatarclover caruso<git@paperclover.net>2026-10-21 19:30:36-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-24 19:01:23-07:00
log3adad9767eb19ab651b35e1f76b7f4a358df0225
tree4b15a94d6db7d52f9542b42f71d8f3786e25b533
parent8bc89c9ebdfc6894c2903e5954c9d720fef9e108
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Publish public MCP server discovery

Expose /.well-known/mcp-servers using the versioned discovery format, deriving endpoints and OAuth scopes from the active catalogs and configured origin. Keep MCP transport authentication intact and cover discovery in the authentication integration checks. Assisted-by: gpt-6-astra

3 files changed, 43 insertions(+), 0 deletions(-)

dashboard/src/main.rs+1
......@@ -587,6 +587,7 @@ async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
587587 .route("/api/{*path}", any(api))
588588 .route("/auth/{*path}", any(auth::route))
589589 .route("/.well-known/openid-configuration", any(oidc::route))
590 .route("/.well-known/mcp-servers", axum::routing::get(mcp::discovery))
590591 .route("/oauth/{*path}", any(mcp::oauth))
591592 .route("/.well-known/{*path}", any(mcp::oauth))
592593 .nest_service("/assets", ServeDir::new(format!("{dist}/assets")))
dashboard/src/mcp.rs+21
......@@ -575,8 +575,29 @@ pub fn router<H: rmcp::ServerHandler>(
575575 ))
576576}
577577
578pub async fn discovery(State(app): State<Arc<App>>) -> axum::Json<Value> {
579 axum::Json(json!({
580 "version": "1.0",
581 "servers": CATALOGS.iter().map(|(id, name, scopes)| json!({
582 "name": id,
583 "description": name,
584 "url": app.mcp.resource(id),
585 "transport": "streamable-http",
586 "authentication": {
587 "type": "oauth2",
588 "required": true,
589 "authorization_url": app.mcp.origin.join("oauth/authorize").unwrap().as_str(),
590 "scopes": scopes,
591 },
592 "capabilities": ["tools"],
593 })).collect::<Vec<_>>(),
594 "registry": {"name": "Snow Globe", "version": env!("CARGO_PKG_VERSION")},
595 }))
596}
597
578598pub fn public(path: &str) -> bool {
579599 path == "/.well-known/openid-configuration"
600 || path == "/.well-known/mcp-servers"
580601 || path.starts_with("/oauth/")
581602 || CATALOGS.iter().any(|(id, _, _)| {
582603 path == format!("/mcp/{id}") || path.starts_with(&format!("/mcp/{id}/"))
tools/dashboard-auth-test.py+21
......@@ -113,6 +113,27 @@ def main():
113113 cookies = {}
114114 start()
115115 try:
116 discovery = '/.well-known/mcp-servers'
117 public_headers = {'Snowglobe-Proxy-Token': '', 'Host': 'untrusted.example',
118 'X-Forwarded-Host': 'untrusted.example', 'X-Forwarded-Proto': 'http'}
119 catalog = request(discovery, extra=public_headers)
120 assert catalog['version'] == '1.0'
121 assert catalog['registry']['name'] == 'Snow Globe'
122 assert {'observability', 'shale'} <= {entry['name'] for entry in catalog['servers']}
123 for entry in catalog['servers']:
124 endpoint = '/mcp/' + entry['name']
125 assert entry['description'] and entry['url'] == origin + endpoint
126 assert entry['transport'] == 'streamable-http' and entry['capabilities'] == ['tools']
127 fields = request(endpoint, status=401, extra={'Snowglobe-Proxy-Token': ''}, include_headers=True)
128 metadata = '/.well-known/oauth-protected-resource' + endpoint
129 assert fields['www-authenticate'] == 'Bearer resource_metadata="' + origin + metadata + '"'
130 protected = request(metadata, extra=public_headers)
131 assert protected['resource'] == entry['url']
132 assert entry['authentication'] == {'type': 'oauth2', 'required': True,
133 'authorization_url': origin + '/oauth/authorize', 'scopes': protected['scopes_supported']}
134 assert request(discovery, 'HEAD', extra=public_headers)['content-type'] == 'application/json'
135 request(discovery, 'POST', {}, status=405, extra=public_headers)
136 request(discovery + '/private', status=403, extra=public_headers)
116137 (data / 'pictures').mkdir(exist_ok=True)
117138 (data / 'pictures' / actor).write_bytes(base64.b64decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Wl6qWQAAAAASUVORK5CYII='))
118139 picture_headers = request('/api/account/pictures/' + actor, include_headers=True)