-
-
Notifications
You must be signed in to change notification settings - Fork 6
Generate a PRM inside the MCP generated manifest #1184
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -161,4 +161,48 @@ auto generate_mcp_tools(const sourcemeta::core::URITemplateRouterView &router, | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| auto generate_protected_resource_metadata( | ||||||||||
| const sourcemeta::one::Authentication &authentication, | ||||||||||
| const sourcemeta::one::Configuration &configuration, | ||||||||||
| const std::string_view endpoint, sourcemeta::core::JSON &result) -> void { | ||||||||||
| std::string resource{configuration.url}; | ||||||||||
| if (!resource.empty() && resource.back() == '/') { | ||||||||||
| resource.pop_back(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| resource.append(endpoint); | ||||||||||
|
|
||||||||||
| // A client that reads this asks its provider for a token bound to the | ||||||||||
| // resource below, so an issuer whose policy expects a different audience | ||||||||||
| // would mint one this instance refuses. Only an issuer whose policy accepts | ||||||||||
| // that audience can be named without sending the client into a rejection | ||||||||||
| auto servers{sourcemeta::core::JSON::make_array()}; | ||||||||||
| for (const auto index : authentication.governing( | ||||||||||
| sourcemeta::one::Authentication::Path::relative(endpoint))) { | ||||||||||
| assert(index < configuration.authentication.size()); | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This bounds check relies solely on Prompt for AI agents
Suggested change
|
||||||||||
| const auto &entry{configuration.authentication[index]}; | ||||||||||
| if (entry.type != | ||||||||||
| sourcemeta::one::Configuration::AuthenticationEntry::Type::JWT || | ||||||||||
| entry.audience != resource) { | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| sourcemeta::core::JSON issuer{entry.issuer}; | ||||||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||||||||||
| if (!servers.contains(issuer)) { | ||||||||||
| servers.push_back(std::move(issuer)); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (servers.empty()) { | ||||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| result = sourcemeta::core::JSON::make_object(); | ||||||||||
| result.assign("resource", sourcemeta::core::JSON{std::move(resource)}); | ||||||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||||||||||
| result.assign("authorization_servers", std::move(servers)); | ||||||||||
| auto bearer_methods{sourcemeta::core::JSON::make_array()}; | ||||||||||
| bearer_methods.push_back(sourcemeta::core::JSON{"header"}); | ||||||||||
| result.assign("bearer_methods_supported", std::move(bearer_methods)); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| } // namespace sourcemeta::one | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #ifndef SOURCEMETA_ONE_INDEX_ENDPOINTS_H | ||
| #define SOURCEMETA_ONE_INDEX_ENDPOINTS_H | ||
|
|
||
| #include <string_view> // std::string_view | ||
|
|
||
| namespace sourcemeta::one { | ||
|
|
||
| // Every route this instance serves, as a URI template relative to the instance | ||
| // root. The router is populated from here, and whatever else has to name the | ||
| // same endpoint reads it from here rather than spelling it again | ||
|
|
||
| inline constexpr std::string_view ENDPOINT_LIST_DIRECTORY{ | ||
| "/self/v1/api/list{/path*}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_DEPENDENCIES{ | ||
| "/self/v1/api/schemas/dependencies/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_DEPENDENTS{ | ||
| "/self/v1/api/schemas/dependents/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_HEALTH{ | ||
| "/self/v1/api/schemas/health/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_LOCATIONS{ | ||
| "/self/v1/api/schemas/locations/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_POSITIONS{ | ||
| "/self/v1/api/schemas/positions/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_STATS{ | ||
| "/self/v1/api/schemas/stats/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_METADATA{ | ||
| "/self/v1/api/schemas/metadata/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_EVALUATE{ | ||
| "/self/v1/api/schemas/evaluate/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_RDF{ | ||
| "/self/v1/api/schemas/rdf/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_TRACE{ | ||
| "/self/v1/api/schemas/trace/{+schema}"}; | ||
| inline constexpr std::string_view ENDPOINT_SCHEMA_SEARCH{ | ||
| "/self/v1/api/schemas/search"}; | ||
| inline constexpr std::string_view ENDPOINT_HEALTH{"/self/v1/health"}; | ||
| inline constexpr std::string_view ENDPOINT_AUTH_LOGOUT{"/self/v1/auth/logout"}; | ||
| inline constexpr std::string_view ENDPOINT_AUTH_LOGIN{ | ||
| "/self/v1/auth/login/{policy}"}; | ||
| inline constexpr std::string_view ENDPOINT_AUTH_CALLBACK{ | ||
| "/self/v1/auth/callback/{policy}"}; | ||
| inline constexpr std::string_view ENDPOINT_MCP{"/self/v1/mcp"}; | ||
| // Clients that normalise URLs by appending a slash reach the same handler | ||
| inline constexpr std::string_view ENDPOINT_MCP_TRAILING_SLASH{"/self/v1/mcp/"}; | ||
| inline constexpr std::string_view ENDPOINT_API_NOT_FOUND{"/self/v1/api/{+any}"}; | ||
| inline constexpr std::string_view ENDPOINT_STATIC{"/self/v1/static/{+path}"}; | ||
|
|
||
| } // namespace sourcemeta::one | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,8 +286,10 @@ inline constexpr DeltaRuleSet<13, 8, 5, 2> INDEX_RULES{ | |
| .filename = "search.metapack"}, | ||
| {.kind = ContainerDependencyKind::ExternalConfig, | ||
| .filename = nullptr}, | ||
| {.kind = ContainerDependencyKind::Global, .filename = nullptr}}}, | ||
| .dependency_count = 3}, | ||
| {.kind = ContainerDependencyKind::Global, .filename = nullptr}, | ||
| {.kind = ContainerDependencyKind::Global, | ||
| .filename = "authentication.bin"}}}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Existing incremental-build outputs keep the old MCP manifest without Prompt for AI agents |
||
| .dependency_count = 4}, | ||
|
|
||
| {.action = ACTION_WEB_INDEX, | ||
| .base = 1, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.