Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/core/mcp/include/sourcemeta/core/mcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,12 @@ auto mcp_make_tool_error(const sourcemeta::core::JSON &identifier,
/// #include <cassert>
///
/// const auto identifier{sourcemeta::core::JSON{3}};
/// const auto envelope{sourcemeta::core::mcp_make_error_resource_not_found(
/// identifier, "file:///missing")};
/// const auto envelope{
/// sourcemeta::core::mcp_make_error_resource_not_found(identifier)};
/// assert(envelope.at("error").at("code").to_integer() == -32002);
/// ```
SOURCEMETA_CORE_MCP_EXPORT
auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier,
const JSON::StringView uri)
auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier)
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/core/mcp/include/sourcemeta/core/mcp.h:329 — Changing mcp_make_error_resource_not_found to drop the uri parameter (and thereby removing error.data from the envelope) is a public API + wire-format change that could break downstream callers expecting the URI to be present somewhere in the error response.

Severity: medium

Other Locations
  • src/core/mcp/mcp.cc:181

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

-> sourcemeta::core::JSON;

/// @ingroup mcp
Expand Down
6 changes: 2 additions & 4 deletions src/core/mcp/mcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,10 @@ auto mcp_make_tool_error(const sourcemeta::core::JSON &identifier,
std::move(envelope_result));
}

auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier,
const JSON::StringView uri)
auto mcp_make_error_resource_not_found(const sourcemeta::core::JSON &identifier)
-> sourcemeta::core::JSON {
return sourcemeta::core::jsonrpc_make_error(
&identifier, MCP_CODE_RESOURCE_NOT_FOUND, "Resource not found",
sourcemeta::core::JSON{uri});
&identifier, MCP_CODE_RESOURCE_NOT_FOUND, "Resource not found");
}

auto mcp_make_resource(const JSON::StringView uri, const JSON::StringView name,
Expand Down
14 changes: 6 additions & 8 deletions test/mcp/mcp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,31 +564,29 @@ TEST(MCP, tool_error_with_null_id) {

TEST(MCP, error_resource_not_found_with_integer_id) {
const auto identifier{sourcemeta::core::JSON{3}};
const auto envelope{sourcemeta::core::mcp_make_error_resource_not_found(
identifier, "file:///missing")};
const auto envelope{
sourcemeta::core::mcp_make_error_resource_not_found(identifier)};
const auto expected{sourcemeta::core::parse_json(R"JSON({
"jsonrpc": "2.0",
"id": 3,
"error": {
"code": -32002,
"message": "Resource not found",
"data": "file:///missing"
"message": "Resource not found"
}
})JSON")};
EXPECT_EQ(envelope, expected);
}

TEST(MCP, error_resource_not_found_with_string_id) {
const auto identifier{sourcemeta::core::JSON{"req-7"}};
const auto envelope{sourcemeta::core::mcp_make_error_resource_not_found(
identifier, "file:///missing")};
const auto envelope{
sourcemeta::core::mcp_make_error_resource_not_found(identifier)};
const auto expected{sourcemeta::core::parse_json(R"JSON({
"jsonrpc": "2.0",
"id": "req-7",
"error": {
"code": -32002,
"message": "Resource not found",
"data": "file:///missing"
"message": "Resource not found"
}
})JSON")};
EXPECT_EQ(envelope, expected);
Expand Down
Loading