You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Marton Greber (Code Review)" <ge...@cloudera.org> on 2026/09/21 13:29:05 UTC

[kudu-CR] KUDU-3806: add the MCP server

Marton Greber has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24908


Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Only actions marked
SURFACE or GATED (see the disposition classification) are advertised;
tool calls are executed by forking `kudu` as a child and collecting
its output with the deadline-bounded Subprocess::WaitAndCollect(), so
a wedged action cannot hang the serve loop. The serve action itself
is classified REJECT to keep the server from re-exposing itself.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, and the JSON-RPC
framing in-process; tool_action_mcp-itest drives the serve loop against
a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
8 files changed, 3,219 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/1
-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 6: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3200/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 6
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 29 Oct 2026 15:20:32 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 4:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3039/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 24 Sep 2026 12:48:06 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 7: Verified+1

unrelated test failures:
asan: org.apache.kudu.spark.tools.DistributedDataGeneratorTest
tsan: java examples failed


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 16:13:36 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 7:

(7 comments)

I took another quick pass; apologies for the delay.

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/mcp_test_util.h
File src/kudu/tools/mcp_test_util.h:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/mcp_test_util.h@122
PS7, Line 122: inline ToolResult ParseToolResult(const std::string& line) {
Here and elsewhere in this file: why to have these methods as inlined when they contain quite many instructions?  Why not to move their implementation into a *.cc file (i.e., mcp_test_util.cc)?


https://gerrit.cloudera.org/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@169
PS1, Line 169: #endif
             :     return with_detail(maybe_partial(std::move(text)));
             :   }
> modelcontextprotocol.info is an unofficial mirror; the canonical spec lives
Thank you for the pointer and extra information in the updated comment.

BTW, the versioning page literally have this note, from which it seems the idea of version in MCP is completely screwed -- they basically state they they don't change the version when adding new features or updating the protocol if maintaining backward compatibility.  That's really interesting approach, indeed:

  The protocol version will not be incremented when the protocol is updated, as long as the changes maintain backwards compatibility. This allows for incremental improvements while preserving interoperability.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@349
PS7, Line 349: HasPrefixString(flag_name, "mcp_")
Wouldn't it miss an override for boolean type flag when prefixed with 'no'?  E.g., if added something like 'mcp_disable_rm' or similar system flag later on -- this check would allow for flipping '--mcp_disable_rm' by adding '--nomcp_disable_rm', meaning that 'rm' isn't disabled anymore?


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@597
PS7, Line 597:             jw->String("default");
             :             jw->String(masters.front());
That's quite strange to have 'default' master address for a multi-master Kudu cluster.  Looks very suspicious as a concept: this can lead to strange behavior down the road when the first address doesn't belong to a leader master.

Is this some sort of slope or it's intentional?


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@814
PS7, Line 814:     if (!google::GetCommandLineFlagInfo(name, &info) || info.is_default) {
             :       continue;
             :     }
When a flag is explicitly set to its default value, is it expected that this short-circuit path results in omitting the flag from the result output?  The comment for the method seems to be a bit confusing in this regard.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1016
PS7, Line 1016: static_cast
nit: is this cast really necessary?


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1578
PS7, Line 1578: bad
In addition to 'bad' there is also 'fail' bit in the stream state: https://en.cppreference.com/cpp/io/ios_base/iostate

Does it make sense to check for failbit as well?

Also, consider adding DCHECK(in.eof()) to make sure it is indeed EOF before returning Status::OK().



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Nov 2026 06:51:14 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 2:

(19 comments)

Thank you for the initial round of review Alexey!

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/mcp_test_util.h
File src/kudu/tools/mcp_test_util.h:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/mcp_test_util.h@44
PS1, Line 44: // The parsed MCP tool result from a 'tools/call' JSON-RPC response. This
            : // deliberately mirrors (rather than reuses) the server's ToolOutcome in
            : // tool_action_mcp.cc: that is the value before JSON serialization, this is the
            : // value parsed back off the wire. Keeping the test's parse-side type
            : //
> This seems duplicated: there is another definition in tool_action_mcp.cc ca
Intentional. They're the two ends of the round-trip: ToolOutcome (tool_action_mcp.cc) is the server-side value before JSON serialization, while ToolResult here is what the test parses back off the wire. They only share fields because that's all the MCP tool-result format carries (a text block + isError), and the swapped field order is just a side effect of them being written independently. Keeping the test's parse-side type independent of the server's type is what makes these helpers an independent oracle of the wire format (see the file comment), so a framing bug in the server can't be masked by a helper that reuses the server's own type. I've added a comment on ToolResult spelling this out so it doesn't read as an accidental clone.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc
File src/kudu/tools/tool_action_mcp-itest.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@24
PS1, Line 24: #include <sys/wait.h>
            : #include <unistd.h>
            : 
            : #include <cerrno>
> nit: for some of these, find corresponding C++ counterparts and move into t
Done - moved <stdint.h> -> <cstdint> and <stdlib.h> -> <cstdlib> into the C++ block. <sys/wait.h> (the W* macros, waitpid) and <unistd.h> (::read/::write) are POSIX-only with no C++ counterpart, so they stay in the C block above.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@90
PS1, Line 90: // parses the tool result. 'arguments_json' is the raw JSON object for
            : // params.arguments.
            : ToolResult CallTool(const string& tool_name, const string& arguments_json) {
            :   
> Why to have this defined in multiple places?  Is it possible to define it o
Moved these into src/kudu/tools/tool_action_mcp-internal.h .


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@684
PS1, Line 684:         << "child interpreted '" << flag_like << "' as a flag: " << tr.text;
             :   }
             : }
             : 
             : } // namespace tools
             : } // namespace kudu
             : 
             : 
             : 
             : 
> Any particular reason of using EXPECT_xxx instead of ASSERT_xxx when tr.is_
No particular one, changed all to ASSERT.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc
File src/kudu/tools/tool_action_mcp-test.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc@299
PS1, Line 299: 
             :   JsonReader reader(line);
             :   NO_FATALS(AssertValidEnvelope(line, &reader));
> Any particular reason of using EXECT_xxx instead of ASSERT_xx here?
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc@411
PS1, Line 411:       scan = t;
> Why EXPECT_FALSE, not ASSERT_FALSE?  Would the rest of the test case make s
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@20
PS1, Line 20: #include <sys/wait.
> nit: convert into '#include <cstdlib>' and move into the section below?
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@93
PS1, Line 93: 
            : // Interprets a finished child tool process into an MCP tool result; see the
            : // declaration in tool_action_mcp-internal.h for the full contract.
            : To
> One more definition of the same entity?  Why do we need so many?
Ah yes, moved this into src/kudu/tools/tool_action_mcp-internal.h


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@169
PS1, Line 169: // stdio, finds a handshake-only server, and falls back to negotiating down to a
             : // version in this set. So this is a capability gap, not a breakage.
             : bool IsSupportedProtocolVersion(c
> This is how versions are defined in MCP?  Wow, that's a piece of innovation
modelcontextprotocol.info is an unofficial mirror; the canonical spec lives at modelcontextprotocol.io.
Versioning section: https://modelcontextprotocol.io/docs/2026-07-28/learn/versioning

Regarding the version based behaviour, I've added explanation comment section here, and the missing latest version 2026-07-28 todo.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@202
PS1, Line 202:     jw->Uint64(id->GetUint64());
             :   } else if (id->IsDouble()) {
             :     jw->Double(
> Isn't this a pure data loss?  If so, wouldn't it make sense to track it som
Valid yes.
Now ClassifyRequest validates the id type. 
Added also a new test: TEST(ToolActionMcpTest, NonScalarIdReturnsInvalidRequestWithNullId) .


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@261
PS1, Line 261: 
> nit for here and elsewhere with lambda captures: is it possible to limit th
Done - narrowed this one to [&protocol_version]. The other BuildResultResponse call sites (BuildResultResponse, BuildErrorResponse, BuildToolsListResponse, BuildToolResultResponse) each capture 1–2 of their own function params and the lambdas are invoked synchronously in place, so I left them as [&]


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@296
PS1, Line 296: xposure registry + reflection into MCP too
> Why this is handled differently from 'allow_writes' above?  Both are suppos
Absolutely, fixed it thanks!


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@427
PS1, Line 427: cleanly, falling back
> IIUC, this case cannot be properly handed by safe_strto64() and requires sa
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@429
PS1, Line 429: teFlagDefault(JsonWriter* jw,
> Here and elsewhere safe_strtoxxx() is used: aren't we supposed to handle an
It basically degrades to emitting the default verbatim as a JSON string, which keeps the schema well-formed.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1225
PS1, Line 1225: list"
> nit for here and elsewhere: please use the same approach for STL classes th
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1253
PS1, Line 1253: nrpc":"2.0", echoes the request id exactly as
              : // sent, and contains EITHER "result" OR "error", never both. Blank lines are
              : // ignored. The loop termina
> What's the purpose of this strange behavior?  Why to keep this nonsensical 
Yes makes sense. Moved this binary patch checking into RunMcpServe before RunMcpServeLoop.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1270
PS1, Line 1270: in, ost
> There are two more characters commonly attributed to the "space" class  in 
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1305
PS1, Line 1305: 
> I'm a bit concerned that unexpected stream errors might entail data loss an
Done


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1327
PS1, Line 1327:  rapidjson::Value* root = reader
> Server-level master addresses?  What are those and how are they different f
Reworded the comment.



-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Sep 2026 12:22:16 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 3: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3027/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 16:36:22 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 7:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3235/


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 13:53:28 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 5: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3056/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 5
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 14:57:24 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 3:

Build Aborted 

http://jenkins.kudu.apache.org/job/pre_commit/3023/ : ABORTED


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 12:03:16 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 1: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3002/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 21 Sep 2026 14:37:43 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Alexey Serbin, Zoltan Martonka, Gabriella Lotz, Attila Bukor, Kudu Jenkins, Yan-Daojiang, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24908

to look at the new patch set (#3).

Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Only actions marked
SURFACE or GATED (see the disposition classification) are advertised;
tool calls are executed by forking `kudu` as a child and collecting
its output with the deadline-bounded Subprocess::WaitAndCollect(), so
a wedged action cannot hang the serve loop. The serve action itself
is classified REJECT to keep the server from re-exposing itself.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, and the JSON-RPC
framing in-process; tool_action_mcp-itest drives the serve loop against
a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-internal.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
9 files changed, 3,362 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/3
-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 3:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3023/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 11:03:47 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 3:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3027/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 12:58:01 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 8:

(4 comments)

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@349
PS7, Line 349: lags negated boolean spelling ('--
> It can't be exploited today. An argument key has to exactly match a propert
Thanks for the update.

The only issue that I might see is that now it's necessary to be careful to not add relevant flags that start with 'no' prefix, even if that 'no' has nothing to do with the semantics of the flags (e.g., something like 'normal_distribution_xxx').


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@597
PS7, Line 597:           jw->String("string");
             :           jw->String("description");
> Yes this is bad. master_remove is GATED and its master_address is the maste
Thanks, now it's looks a bit better to me.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@814
PS7, Line 814: };
             : 
             : // Re
> In gflags 2.2.2, is_default is !modified_, so a flag explicitly set to its 
I'm not exactly sure that's relevant to the case when a flag is set to its default value.  I did this experiment: removed the comparison of currently set value in src/kudu/util/flags.cc:421 and run the tests introduced with http://gerrit.cloudera.org:8080/24151.  FlagsValidatorsDeathTest.TaggedAccepted failed, so it seems 'is_default' wasn't set when the value of the flag is touched.  In other words, !modified_ means that there was some setting for the flag, regardless its actual value.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1578
PS7, Line 1578: hod
> I didn't use a plain fail() check, because std::getline() always sets failb
Yep, always checking for eof() before returning Status::OK() seems a better option.

However, PS8 now checks for fail() before checking for bad().  Please double-check the code in PS8 is as intended.  Thanks!



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 8
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 10 Nov 2026 05:33:22 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Alexey Serbin, Zoltan Martonka, Gabriella Lotz, Attila Bukor, Kudu Jenkins, Yan-Daojiang, 

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/24908

to look at the new patch set (#9).

Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Exposure follows the
disposition classification: SURFACE tools are advertised, GATED
(mutating) tools only with --mcp_allow_writes, and tools tagged as
returning row-level user data only with --mcp_allow_data_reads.
REJECT and EXCLUDE actions are never advertised; the serve action
itself is REJECT to keep the server from re-exposing itself. Calling
a tool hidden by a closed gate fails with an error naming the flag.
GATED tools accept a dry_run argument that returns the exact command
instead of running it.

Each tools/call runs in a fresh child 'kudu' process, so an action
that CHECKs or exits only kills the child. The child's output is
collected with Subprocess::WaitAndCollect(), bounded by a timeout
(--mcp_tool_timeout_sec, or the longer --mcp_gated_tool_timeout_sec
for mutating tools) and by --mcp_max_output_bytes. To keep memory
bounded, WaitAndCollect() gains an optional per-stream byte cap: the
rest of the output is drained and discarded, so the child still runs
to completion. A mutating tool that times out or crashes is reported
as possibly partially applied.

Tool calls are validated strictly: argument keys missing from the
schema are rejected, dry_run must be a boolean, and the cluster is
fixed by the operator -- a per-call master_addresses is rejected, and
a single-master action's master_address must be one of the
configured masters. Client connection and security flags set on
'serve' (--sasl_protocol_name, TLS settings, timeouts) are forwarded
to the child, and positional values are passed after a '--' sentinel
so they are never parsed as child flags. The server also answers
'ping'.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, argument
validation and the JSON-RPC framing in-process; tool_action_mcp-itest
drives the serve loop against a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.cc
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-internal.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
13 files changed, 4,162 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/9
-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 9
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Zoltan Chovan (Code Review)" <ge...@cloudera.org>.
Zoltan Chovan has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 6:

(13 comments)

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp-itest.cc
File src/kudu/tools/tool_action_mcp-itest.cc:

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp-itest.cc@499
PS6, Line 499: TEST_F(ToolActionMcpITest, InterpretChildOutcomeMapsExitSignalAndTimeout) {
InterpretChildOutcome is a pure function and doesn't need a cluster. Move this test to tool_action_mcp-test.cc.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@59
PS6, Line 59: allow_writes
allow_writes is a very generic name for a global gflag in the kudu binary. 
Maybe mcp_allow_writes?


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@109
PS6, Line 109:     return with_detail(Substitute(
On timeout a GATED child is SIGKILLed after possibly applying some or all of its change (hms fix, table create, …). For gated tools the message should say the change may be partially applied and the cluster state should be checked. 
Consider a longer default timeout for gated calls.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@377
PS6, Line 377:     entry.tool_name = McpToolName(chain, action.get());
Tool names come from joining the path with _, so a_b c and a b_c would get the same name. CHECK that names are unique in BuildMcpToolRegistry (:394).


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@702
PS6, Line 702:   if (arg_name == kMasterAddressArg) {
Singular master_address is hidden and always resolves to the first master, so master_status/get_flags/set_flag/dump_memtrackers can only  reach master #0. Expose it as an optional property that defaults to the first master.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@843
PS6, Line 843:     argv.emplace_back(Substitute("--$0=$1", o.first, o.second));
Only the per-call optional flags reach the child. RPC/security flags given to serve (--sasl_protocol_name, --rpc_*, …) are silently not applied to tool calls. Forward an allowlist or document this.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@893
PS6, Line 893:   return p.WaitAndCollect(MonoDelta::FromSeconds(timeout_seconds),
Captured stdout/stderr has no size limit. table scan, wal dump or ksck --checksum_scan can produce GBs within the timeout. Add a --mcp_max_output_bytes limit that truncates with a [truncated] marker.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@975
PS6, Line 975:     if (dr != nullptr && dr->IsBool()) {
A non-bool dry_run ("true", 1) is silently ignored and the gated tool executes. Reject a present-but-non-bool dry_run with -32602.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@995
PS6, Line 995:               Substitute("Invalid params: '$0' must be a string", r.name));
Nit: this error says "must be a string" while :1019 / :1064 say "must be a scalar". Make the wording consistent.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@998
PS6, Line 998:         value = InjectedConnectionValue(r.name);
A caller-supplied master_addresses / master_address overrides the configured value. The model can then aim tools at any cluster using the operator's Kerberos credentials, which contradicts the docs. Forbid the override (preferred), or document it and expose it in the schema.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1067
PS6, Line 1067:     optional_supplied.emplace_back(o.name, std::move(value));
Unknown argument keys are silently dropped, so a typo such as dryrun or a misspelled flag still runs the tool. Reject keys that aren't in the schema, at least for GATED tools.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1227
PS6, Line 1227:   if (method == "tools/call") {
No ping handler: the MCP spec says servers must answer it, and it currently gets -32601. notifications/cancelled is also ignored, so a running call can't be cancelled. Add ping, and list cancellation under limitations.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1373
PS6, Line 1373:       .AddOptionalParameter("allow_writes")
-mcp_tool_timeout_sec isn't registered via AddOptionalParameter, so it doesn't appear in kudu mcp serve --help.



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 6
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 12:08:02 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Zoltan Chovan (Code Review)" <ge...@cloudera.org>.
Zoltan Chovan has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 7: Code-Review+2


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 15:01:43 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Alexey Serbin, Zoltan Martonka, Gabriella Lotz, Attila Bukor, Kudu Jenkins, Yan-Daojiang, 

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/24908

to look at the new patch set (#8).

Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Exposure follows the
disposition classification: SURFACE tools are advertised, GATED
(mutating) tools only with --mcp_allow_writes, and tools tagged as
returning row-level user data only with --mcp_allow_data_reads.
REJECT and EXCLUDE actions are never advertised; the serve action
itself is REJECT to keep the server from re-exposing itself. Calling
a tool hidden by a closed gate fails with an error naming the flag.
GATED tools accept a dry_run argument that returns the exact command
instead of running it.

Each tools/call runs in a fresh child 'kudu' process, so an action
that CHECKs or exits only kills the child. The child's output is
collected with Subprocess::WaitAndCollect(), bounded by a timeout
(--mcp_tool_timeout_sec, or the longer --mcp_gated_tool_timeout_sec
for mutating tools) and by --mcp_max_output_bytes. To keep memory
bounded, WaitAndCollect() gains an optional per-stream byte cap: the
rest of the output is drained and discarded, so the child still runs
to completion. A mutating tool that times out or crashes is reported
as possibly partially applied.

Tool calls are validated strictly: argument keys missing from the
schema are rejected, dry_run must be a boolean, and the cluster is
fixed by the operator -- a per-call master_addresses is rejected, and
a single-master action's master_address must be one of the
configured masters. Client connection and security flags set on
'serve' (--sasl_protocol_name, TLS settings, timeouts) are forwarded
to the child, and positional values are passed after a '--' sentinel
so they are never parsed as child flags. The server also answers
'ping'.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, argument
validation and the JSON-RPC framing in-process; tool_action_mcp-itest
drives the serve loop against a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.cc
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-internal.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
13 files changed, 4,142 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/8
-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 8
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 8:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3294/


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 8
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Nov 2026 13:52:48 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 9:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3374/


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 9
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 11 Nov 2026 11:19:22 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 1:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3002/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Mon, 21 Sep 2026 13:29:14 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 4: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3039/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 24 Sep 2026 14:31:07 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 8: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3294/ : FAILURE


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 8
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Nov 2026 16:52:11 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 6:

(13 comments)

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp-itest.cc
File src/kudu/tools/tool_action_mcp-itest.cc:

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp-itest.cc@499
PS6, Line 499: TEST_F(ToolActionMcpITest, InterpretChildOutcomeMapsExitSignalAndTimeout) {
> InterpretChildOutcome is a pure function and doesn't need a cluster. Move t
The InterpretChildOutcome test now lives in tool_action_mcp-test.cc and no longer needs a cluster.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@59
PS6, Line 59: allow_writes
> allow_writes is a very generic name for a global gflag in the kudu binary. 
Renamed the flag to --mcp_allow_writes. The data-read gate is --mcp_allow_data_reads. Every mcp_* name is now reserved, so the model can't set any of them per call.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@109
PS6, Line 109:     return with_detail(Substitute(
> On timeout a GATED child is SIGKILLed after possibly applying some or all o
if a GATED tool times out or dies by a signal, the error now says its change "may have been partially or fully applied. Check the cluster state before retrying". GATED calls also get their own timeout, --mcp_gated_tool_timeout_sec, default 300 seconds (read-only calls stay at 60).


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@377
PS6, Line 377:     entry.tool_name = McpToolName(chain, action.get());
> Tool names come from joining the path with _, so a_b c and a b_c would get 
BuildMcpToolRegistry CHECKs that tool names are unique and names both clashing command paths. It's now built on the shared VisitActions().


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@702
PS6, Line 702:   if (arg_name == kMasterAddressArg) {
> Singular master_address is hidden and always resolves to the first master, 
master_address is an optional property. Its schema lists the configured masters as an enum, with the first as the default. Any other value gets -32602.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@843
PS6, Line 843:     argv.emplace_back(Substitute("--$0=$1", o.first, o.second));
> Only the per-call optional flags reach the child. RPC/security flags given 
the server forwards a fixed list of flags to each tool process, but only flags the operator actually set on serve: sasl_protocol_name, negotiation_timeout_ms, timeout_ms, tls_min_version, tls_ciphers, tls_ciphersuites, rpc_max_message_size. These are the client-side flags tool_action_common.cc reads; the other rpc_* flags are server-side and the CLI ignores them. A per-call value wins, and dry-run output shows the forwarded flags.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@893
PS6, Line 893:   return p.WaitAndCollect(MonoDelta::FromSeconds(timeout_seconds),
> Captured stdout/stderr has no size limit. table scan, wal dump or ksck --ch
added --mcp_max_output_bytes, default 1 MiB per stream, 0 for no limit. The cap is applied while reading, so memory stays bounded. The rest of the output is read and thrown away, so the tool still finishes normally, and the result ends with a [truncated: ...] marker.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@975
PS6, Line 975:     if (dr != nullptr && dr->IsBool()) {
> A non-bool dry_run ("true", 1) is silently ignored and the gated tool execu
a dry_run that isn't a boolean now gets -32602.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@995
PS6, Line 995:               Substitute("Invalid params: '$0' must be a string", r.name));
> Nit: this error says "must be a string" while :1019 / :1064 say "must be a 
every scalar check now says "argument 'x' must be a scalar".


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@998
PS6, Line 998:         value = InjectedConnectionValue(r.name);
> A caller-supplied master_addresses / master_address overrides the configure
a per-call master_addresses is rejected ("cannot be overridden per call"), even when the server has no addresses configured.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1067
PS6, Line 1067:     optional_supplied.emplace_back(o.name, std::move(value));
> Unknown argument keys are silently dropped, so a typo such as dryrun or a m
argument keys that aren't in the schema are rejected for all tools, not only GATED ones. One side effect: dry_run on a SURFACE tool used to be silently ignored and is now rejected.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1227
PS6, Line 1227:   if (method == "tools/call") {
> No ping handler: the MCP spec says servers must answer it, and it currently
added a ping handler that returns {}. Cancellation goes on the docs limitations list.


https://gerrit.cloudera.org/#/c/24908/6/src/kudu/tools/tool_action_mcp.cc@1373
PS6, Line 1373:       .AddOptionalParameter("allow_writes")
> -mcp_tool_timeout_sec isn't registered via AddOptionalParameter, so it does
all mcp_* flags are registered with AddOptionalParameter, and a test checks that none is missing.



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 6
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 13:53:40 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Alexey Serbin, Zoltan Martonka, Gabriella Lotz, Attila Bukor, Kudu Jenkins, Yan-Daojiang, 

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/24908

to look at the new patch set (#7).

Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Exposure follows the
disposition classification: SURFACE tools are advertised, GATED
(mutating) tools only with --mcp_allow_writes, and tools tagged as
returning row-level user data only with --mcp_allow_data_reads.
REJECT and EXCLUDE actions are never advertised; the serve action
itself is REJECT to keep the server from re-exposing itself. Calling
a tool hidden by a closed gate fails with an error naming the flag.
GATED tools accept a dry_run argument that returns the exact command
instead of running it.

Each tools/call runs in a fresh child 'kudu' process, so an action
that CHECKs or exits only kills the child. The child's output is
collected with Subprocess::WaitAndCollect(), bounded by a timeout
(--mcp_tool_timeout_sec, or the longer --mcp_gated_tool_timeout_sec
for mutating tools) and by --mcp_max_output_bytes. To keep memory
bounded, WaitAndCollect() gains an optional per-stream byte cap: the
rest of the output is drained and discarded, so the child still runs
to completion. A mutating tool that times out or crashes is reported
as possibly partially applied.

Tool calls are validated strictly: argument keys missing from the
schema are rejected, dry_run must be a boolean, and the cluster is
fixed by the operator -- a per-call master_addresses is rejected, and
a single-master action's master_address must be one of the
configured masters. Client connection and security flags set on
'serve' (--sasl_protocol_name, TLS settings, timeouts) are forwarded
to the child, and positional values are passed after a '--' sentinel
so they are never parsed as child flags. The server also answers
'ping'.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, argument
validation and the JSON-RPC framing in-process; tool_action_mcp-itest
drives the serve loop against a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-internal.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
12 files changed, 4,017 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/7
-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 5:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3056/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 5
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 13:38:31 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 2:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3016/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Sep 2026 12:20:21 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 9:

(3 comments)

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@349
PS7, Line 349: lags negated boolean spelling ('--
> Thanks for the update.
Good point. To make it robust to that, IsReservedControlFlag() now checks the name both as spelled and with a leading 'no' stripped (new helper IsReservedName()). So a reserved name that itself begins with 'no' is still matched as-is, and an unrelated 'no...' name like 'normal_distribution_xxx' is unaffected: stripped it becomes 'rmal_distribution_xxx', which isn't reserved either. The comment now spells this out.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@814
PS7, Line 814: // Client-side connection and security flags that the child 'kudu' honors when
             : // it talks to the cluster (see BuildMessenger() / CreateKuduClient() in
             : // to
> I'm not exactly sure that's relevant to the case when a flag is set to its 
Thanks for running the experiment. I think it confirms the same thing from the other side: is_default is false once the flag has been assigned at all, whatever the value. So a forwarded flag explicitly set to its default stays non-default and is forwarded, and that's what ServeConnectionFlagExplicitlySetToDefaultIsForwarded pins down. CheckFlagsAndWarn() adds the 'default_value == current_value' check because it wants to ignore a no-op setting. Here I left that filter out on purpose: the child would resolve to the same value anyway, and the dry-run output stays an exact echo of what the operator passed to serve. I added a comment saying this.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1578
PS7, Line 1578: ne.
> Yep, always checking for eof() before returning Status::OK() seems a better
The fail() and bad() checks in PS8 are on different streams: out.fail() is stdout and in.bad() is stdin. For the input, the order is bad() then !eof(), since getline() always sets failbit at the end. For the output, fail() is the right check, since nothing sets failbit on a healthy ostream. I see how the order made this look like the same stream, so in the new PS the input checks come first and the output check second, each with a comment naming the stream.



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 9
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 11 Nov 2026 11:21:58 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 7: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3235/ : FAILURE


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Nov 2026 16:08:31 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has removed a vote on this change.

Change subject: KUDU-3806: add the MCP server
......................................................................


Removed Verified-1 by Kudu Jenkins (120)
-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteVote
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 7
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 8:

(6 comments)

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/mcp_test_util.h
File src/kudu/tools/mcp_test_util.h:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/mcp_test_util.h@122
PS7, Line 122: 
> Here and elsewhere in this file: why to have these methods as inlined when 
I moved all the bodies into a new mcp_test_util.cc, added to the kudu_tools_test_util library. The header now has only declarations and the ToolResult struct.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@349
PS7, Line 349: lags negated boolean spelling ('--
> Wouldn't it miss an override for boolean type flag when prefixed with 'no'?
It can't be exploited today. An argument key has to exactly match a property the action declares, and each one becomes a single --name=value argv element. Also, the gates are enforced in the server process, not the child. I hardened it anyway: IsReservedControlFlag() now strips a leading no before checking, with a comment explaining why. I didn't add a test, because the function is in the anonymous namespace.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@597
PS7, Line 597:           jw->String("string");
             :           jw->String("description");
> That's quite strange to have 'default' master address for a multi-master Ku
Yes this is bad. master_remove is GATED and its master_address is the master to remove, so a call that left it out would remove the first configured master. master_address is now:
   - required (in required[]),
   - limited by an enum to the configured masters,
   - without a default.

Leaving it out returns -32602 with the valid choices listed. Tests are updated, and the renamed MasterAddressIsRequiredAndRestrictedToConfiguredMasters now covers master_status and master_remove being called without it.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@814
PS7, Line 814: };
             : 
             : // Re
> When a flag is explicitly set to its default value, is it expected that thi
In gflags 2.2.2, is_default is !modified_, so a flag explicitly set to its default value is still forwarded. I rewrote the comment and added ServeConnectionFlagExplicitlySetToDefaultIsForwarded to pin that behavior.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1016
PS7, Line 1016: );
> nit: is this cast really necessary?
Removed. The validator already guarantees mcp_max_output_bytes >= 0.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1578
PS7, Line 1578: hod
> In addition to 'bad' there is also 'fail' bit in the stream state: https://
I didn't use a plain fail() check, because std::getline() always sets failbit when it hits EOF, so that would reject a normal shutdown. Instead it now checks bad() and then !in.eof(), which catches failbit set without EOF and returns an IOError. I left out the suggested DCHECK(in.eof()): it would sit right after that check, so it would be redundant, and the check also runs in release builds. On the output side, out.bad() became out.fail() in both places.



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 8
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Nov 2026 13:53:05 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 2:

Build Aborted 

http://jenkins.kudu.apache.org/job/pre_commit/3016/ : ABORTED


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 11:03:39 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 1:

(19 comments)

Thank you for putting this together!

I took a quick glance, posting a few notes.

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/mcp_test_util.h
File src/kudu/tools/mcp_test_util.h:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/mcp_test_util.h@44
PS1, Line 44: // The parsed MCP tool result from a 'tools/call' JSON-RPC response.
            : struct ToolResult {
            :   bool is_error;
            :   std::string text;  // content[0].text
            : };
This seems duplicated: there is another definition in tool_action_mcp.cc called ToolOutput, with the field order swapped.  Is it intentional?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc
File src/kudu/tools/tool_action_mcp-itest.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@24
PS1, Line 24: #include <stdint.h>
            : #include <stdlib.h>
            : #include <sys/wait.h>
            : #include <unistd.h>
nit: for some of these, find corresponding C++ counterparts and move into the section below


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@90
PS1, Line 90: struct ToolOutcome {
            :   string text;
            :   bool is_error;
            : };
Why to have this defined in multiple places?  Is it possible to define it one common place and use everywhere?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-itest.cc@684
PS1, Line 684:     EXPECT_NE(string::npos, tr.text.find("does not exist"))
             :         << "expected a 'table does not exist' error for '" << flag_like
             :         << "', got: " << tr.text;
             :     EXPECT_NE(string::npos, tr.text.find(flag_like))
             :         << "error should echo the literal table name '" << flag_like
             :         << "', got: " << tr.text;
             :     // The child version banner must never appear: that would mean "--version" was
             :     // parsed as a flag and the describe action never ran.
             :     EXPECT_EQ(string::npos, tr.text.find("build type"))
             :         << "child interpreted '" << flag_like << "' as a flag: " << tr.text;
Any particular reason of using EXPECT_xxx instead of ASSERT_xxx when tr.is_error is handled with ASSERT_TRUE() in the same loop?

Similar question elsewhere in this file regarding EXPECT vs ASSERT usage.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc
File src/kudu/tools/tool_action_mcp-test.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc@299
PS1, Line 299:   EXPECT_TRUE(Contains(names, "table_describe")) << line;
             :   EXPECT_TRUE(Contains(names, "master_status")) << line;
             :   EXPECT_FALSE(Contains(names, "table_delete")) << line;
Any particular reason of using EXECT_xxx instead of ASSERT_xx here?

Same for everywhere else in this file.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp-test.cc@411
PS1, Line 411:   EXPECT_FALSE(Contains(ToolNames(RunToolsList(false)), "table_delete"));
Why EXPECT_FALSE, not ASSERT_FALSE?  Would the rest of the test case make sense if this triggers?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@20
PS1, Line 20: #include <stdlib.h>
nit: convert into '#include <cstdlib>' and move into the section below?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@93
PS1, Line 93: struct ToolOutcome {
            :   string text;
            :   bool is_error;
            : };
One more definition of the same entity?  Why do we need so many?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@169
PS1, Line 169:   return version == "2024-11-05" ||
             :          version == "2025-03-26" ||
             :          version == "2025-06-18";
This is how versions are defined in MCP?  Wow, that's a piece of innovation, indeed.

I guess none is backward-compatible with any other one, right?  If so, then how this server can support all the three out of the box -- I didn't see any code that would change its behavior based on the version, but maybe I'm missing something?

Also, 2025-03-26 doesn't match any version documented here: https://modelcontextprotocol.info/specification/  What's so special about 2025-03-26 that it's mentioned here?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@202
PS1, Line 202:     // Bool/object/array are not valid JSON-RPC ids. Echo null to stay
             :     // well-formed rather than propagating a nonsensical id.
             :     jw->Null();
Isn't this a pure data loss?  If so, wouldn't it make sense to track it somehow at least during development phase to understand that the generated JSON value isn't fit for MCP consumers?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@261
PS1, Line 261: &
nit for here and elsewhere with lambda captures: is it possible to limit the scope only to 'protocol_version' or there is anything else that the lambda needs from the outside context?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@296
PS1, Line 296: flag_name.find("dry_run") != string::npos;
Why this is handled differently from 'allow_writes' above?  Both are supposed to be boolean flags, so noallow_writes and nodry_run should be treated similarly, no?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@427
PS1, Line 427: flag_type == "uint64"
IIUC, this case cannot be properly handed by safe_strto64() and requires safe_strtou64().


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@429
PS1, Line 429: safe_strto64(default_value, &v)
Here and elsewhere safe_strtoxxx() is used: aren't we supposed to handle an error if safe_strto64() returns false?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1225
PS1, Line 1225: std::
nit for here and elsewhere: please use the same approach for STL classes that appear at least twice -- add corresponding 'using ...' directive in the beginning of the file and drop the 'std' namespace prefix


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1253
PS1, Line 1253: If the binary cannot be located we keep serving:
              :   // HandleToolsCall turns an empty path into an isError tool result rather than
              :   // taking the server down.
What's the purpose of this strange behavior?  Why to keep this nonsensical situation instead of reporting an error early and exiting, similar to failed flag validator or ValidateDispositionCoverageOrDie() above?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1270
PS1, Line 1270:  \t\r\n
There are two more characters commonly attributed to the "space" class  in the ASCII character set: vertical tab '\v', form feed '\f'.


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1305
PS1, Line 1305: or a stream error
I'm a bit concerned that unexpected stream errors might entail data loss and lead to hard-to-troubleshoot situations with this sloppy always-OK return approach.  Why not to treat stream errors with non-OK return status?


http://gerrit.cloudera.org:8080/#/c/24908/1/src/kudu/tools/tool_action_mcp.cc@1327
PS1, Line 1327: The serve-level master addresses
Server-level master addresses?  What are those and how are they different from client-level master addresses?



-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Sep 2026 03:26:59 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Alexey Serbin, Zoltan Martonka, Gabriella Lotz, Attila Bukor, Kudu Jenkins, Yan-Daojiang, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24908

to look at the new patch set (#2).

Change subject: KUDU-3806: add the MCP server
......................................................................

KUDU-3806: add the MCP server

Add `kudu mcp serve`, a Model Context Protocol server that speaks
JSON-RPC over stdio and exposes the CLI as callable tools so an MCP
client (an LLM agent) can drive Kudu.

The server reconstructs the full action tree via BuildRootMode() and
reflects each action's flags into a tool schema. Only actions marked
SURFACE or GATED (see the disposition classification) are advertised;
tool calls are executed by forking `kudu` as a child and collecting
its output with the deadline-bounded Subprocess::WaitAndCollect(), so
a wedged action cannot hang the serve loop. The serve action itself
is classified REJECT to keep the server from re-exposing itself.

Coverage is enforced at startup by ValidateDispositionCoverageOrDie().
tool_action_mcp-test exercises reflection, dispatch, and the JSON-RPC
framing in-process; tool_action_mcp-itest drives the serve loop against
a live ExternalMiniCluster.

Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/tools/CMakeLists.txt
A src/kudu/tools/mcp_test_util.h
M src/kudu/tools/tool_action.h
A src/kudu/tools/tool_action_mcp-internal.h
A src/kudu/tools/tool_action_mcp-itest.cc
A src/kudu/tools/tool_action_mcp-test.cc
A src/kudu/tools/tool_action_mcp.cc
A src/kudu/tools/tool_action_mcp.h
M src/kudu/tools/tool_action_root.cc
9 files changed, 3,363 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/08/24908/2
-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 6:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3200/


-- 
To view, visit http://gerrit.cloudera.org:8080/24908
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 6
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 29 Oct 2026 13:15:42 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 9: Verified+1

Build Successful 

http://jenkins.kudu.apache.org/job/pre_commit/3374/ : SUCCESS


-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 9
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 11 Nov 2026 12:28:34 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add the MCP server

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( https://gerrit.cloudera.org/24908 )

Change subject: KUDU-3806: add the MCP server
......................................................................


Patch Set 9: Code-Review+2

(2 comments)

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc
File src/kudu/tools/tool_action_mcp.cc:

https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@814
PS7, Line 814: // Client-side connection and security flags that the child 'kudu' honors when
             : // it talks to the cluster (see BuildMessenger() / CreateKuduClient() in
             : // to
> Thanks for running the experiment. I think it confirms the same thing from 
Thank you for the clarification -- with more context now I see it behaves as expected.


https://gerrit.cloudera.org/#/c/24908/7/src/kudu/tools/tool_action_mcp.cc@1578
PS7, Line 1578: ne.
> The fail() and bad() checks in PS8 are on different streams: out.fail() is 
Ah, indeed: I missed it was different stream.  Thank for the update  to re-order those: this way it's easier to read and a bit more consistent with reporting on stream status.



-- 
To view, visit https://gerrit.cloudera.org/24908
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I59146a2fd4f5b8d61d3e494cc88974b396ed6856
Gerrit-Change-Number: 24908
Gerrit-PatchSet: 9
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Yan-Daojiang <ya...@163.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 12 Nov 2026 19:43:29 +0000
Gerrit-HasComments: Yes