Implementation Families, Registry, and Dynamic MCP
xai-grok-tools houses multiple sets of built-in tool implementations alongside runtime MCP tools. ToolBridge connects the registry to the session layer, while SearchTool and UseTool provide the discovery and invocation entry points.
ToolBridge; accurately reproduce the real input fields for both MCP meta-tools.
grok_buildPrimary product tool family, containing ReadFile, SearchReplace, Bash, Task, and other implementations.
grok_build_conciseLean tool family; directory contains read_file, search_replace, and bash.
grok_build_hashlineread_file, edit, and grep implementations with hashline semantics.
codexContains apply_patch, read_file, list_dir, grep_files, and other compatible implementations.
opencodeContains read, write, edit, bash, glob, grep, skill, and todowrite.
memory / lsp / skillsImplementation modules split by capability. The namespace enum also includes MCP for runtime external tools.
SearchTool
Searches MCP tools in ToolIndex using BM25. Results are grouped by server and return tool descriptions with input_schema.
query: Stringkeywordlimit: Option<u8>default 5UseTool
Accepts a discovered tool name and invokes MCP via InnerDispatch or a managed gateway. This fixed entry point keeps the model's tool list stable across turns.
tool_name: Stringtypically server__tooltool_input: Valueconstructed per discovered schemapub struct ToolBridge {
registry: Arc<FinalizedToolset>,
terminal: Option<Arc<dyn TerminalBackend>>,
}
pub async fn register_mcp_tools<T>(
&self,
mcp_name: String,
tool: T,
input_schema: Option<serde_json::Value>,
) -> Result<(), xai_tool_runtime::ToolError> {
self.registry.register_tool(mcp_name, tool, input_schema)?;
Ok(())
}
pub struct UseToolInput {
pub tool_name: String,
pub tool_input: serde_json::Value,
}
grok-build-main. Key files cross-referenced: xai-grok-tools/src/implementations/mod.rs, types/tool.rs, bridge.rs, registry/types.rs, implementations/search_tool, and implementations/use_tool. Verified 2026-07-17.Trace an External Tool Call
Starting from the model's initial call to search_tool, write down the query field, the schema to read from the response, the two fields then passed to use_tool, and which bridge type ultimately returns the result to the session.
ToolBridge connects to the session. Dynamic MCP discovers schemas via SearchTool, then dispatches execution via UseTool according to the discovered schema.