feat(tools): native tool integration for MCP and Ollama (#940)#947
Merged
feat(tools): native tool integration for MCP and Ollama (#940)#947
Conversation
…actor Phase 1 — MCP native tools: - McpToolExecutor implements tool_definitions() and execute_tool_call(), exposing MCP tools as native ToolDefinitions (qualified server:tool names) - McpState.shared_tools (Arc<RwLock<Vec<McpTool>>>) wired through builder and synced on /mcp add/remove - append_mcp_prompt() skips text injection when provider.supports_tool_use() Phase 2 — Ollama native tool calling: - OllamaProvider implements supports_tool_use() and chat_with_tools() via ollama_rs tool API - OllamaConfig.tool_use flag (default false); enable with llm.ollama.tool_use = true in config Refactor — ToolDef.id/description changed from &'static str to Cow<'static, str> to support dynamic MCP tool names; all call sites updated Closes #940
This was
linked to
issues
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ToolDefinitions viaMcpToolExecutor.tool_definitions()and dispatched throughexecute_tool_call()using qualifiedserver:toolnames. MCP text prompt injection is suppressed when the provider supports native tool_use. Tool list stays in sync with/mcp add//mcp removevia sharedArc<RwLock<Vec<McpTool>>>.OllamaProvidernow supports native tool calling viachat_with_tools()using theollama_rstool API. Opt-in viallm.ollama.tool_use = true(default: false).ToolDef.id/descriptionchanged from&'static strtoCow<'static, str>to accommodate dynamic MCP tool names.Test plan
cargo nextest run --workspace --lib --bins— 2866 tests passcargo clippy --workspace -- -D warnings— cleancargo +nightly fmt --check— cleanllm.ollama.tool_use = truewith llama3.1+, verify tool calls round-tripCloses #940