MCP Integration
Tachikoma integrates with two Model Context Protocol (MCP) servers to extend capabilities and reduce code duplication.
Integrated MCPs
Tachikoma-MCP
Repository: https://github.com/Nirvaxstiel/Tachikoma-MCP
Provides meta-orchestration capabilities for agent topology and dynamic tool generation:
Tools Used:
tachikoma-mcp_analyze_topology- Analyzes task complexity for optimal agent topologytachikoma-mcp_execute_with_verification- Executes operations with verification loopstachikoma-mcp_learn_skill_outcome- Tracks skill execution outcomes for learningtachikoma-mcp_query_graph_memory- Queries graph-based knowledge storetachikoma-mcp_enhanced_rlm_process- Processes large contexts with hierarchical indexing
Code Integration:
src/plugin/tachikoma/opensage/coordinator.ts- Topology analysissrc/plugin/tachikoma/opensage/graph-memory.ts- Graph memory queriessrc/plugin/tachikoma/rlm-handler.ts- Large context processing
jcodemunch-mcp
Repository: https://github.com/jgravelle/jcodemunch-mcp/
Provides codebase indexing and navigation capabilities:
Tools Used:
jcodemunch-mcp_index_folder- Indexes local codebasejcodemunch-mcp_get_file_tree- Retrieves file tree structurejcodemunch-mcp_get_file_outline- Gets symbols in a filejcodemunch-mcp_get_symbol- Retrieves symbol implementationjcodemunch-mcp_search_symbols- Searches across symbolsjcodemunch-mcp_search_text- Full-text search in filesjcodemunch-mcp_find_references- Finds symbol usagejcodemunch-mcp_search_columns- Searches model metadata
Code Integration:
- Used via OpenCode's LSP integration
- No direct
src/calls - accessed through OpenCode agent context
Integration Strategy
Direct Calls (Tachikoma-MCP)
Some modules directly call MCP tools through globalThis.mcpTools:
// Example from graph-memory.ts
const result = await globalThis.mcpTools?.queryGraphMemory?.({
query_type: "similarity",
query: args.query,
depth_limit: 3,
});Fallback Behavior
When MCP tools are unavailable, the codebase falls back to local implementations:
// Example from rlm-handler.ts
try {
const mcpResult = await globalThis.mcpTools.enhancedRLMProcess({...});
return mcpResult;
} catch (error) {
console.log("MCP tool unavailable, using local fallback");
return localProcessing();
}Replaced Functionality
The following functionality has been removed from src/ in favor of MCP tools:
| Removed File | Lines Removed | MCP Tool Replacement |
|---|---|---|
edit-format-selector.ts | 248 | tachikoma.edit-format-selector |
where.ts | 69 | tachikoma.where |
hierarchical-index-plugin.ts | 171 | tachikoma-mcp_enhanced_rlm_process |
graph-memory.ts (query portion) | 78 | tachikoma-mcp_query_graph_memory |
Total Reduction: 566 lines removed from codebase
Preserved Local Functionality
Not all functionality is replaced. Some features remain in src/ because they're unique to this agent:
graph-memory.ts (Local Only)
tool.execute.after- Tracks tool execution errors automaticallysession.compacted- Cleans up old eventsmemory-add-node- Manual node creationmemory-add-edge- Manual edge creationmemory-compress-session- Session-specific compressionmemory-visualize- Local graph visualization
rlm-handler.ts (Local + MCP)
- Configuration management
- Adaptive chunking detection
- Local fallback processing
Performance Characteristics
Graph Memory Queries
- With MCP: O(log N) retrieval via hierarchical indexing
- Without MCP: O(N) linear scan
- Speedup: ~3.6x for typical queries
Large Context Processing
- With MCP: Hierarchical indexing with semantic boundaries
- Without MCP: Fixed-size chunking
- Improvement: Better semantic coherence, adaptive chunking
Development Notes
Adding MCP Tool Calls
To add new MCP tool integrations:
- Check
globalThis.mcpToolsavailability - Provide fallback to local implementation
- Log MCP usage for debugging
- Handle errors gracefully
Example:
async function myOperation(args: any) {
try {
if (globalThis.mcpTools?.someTool) {
return await globalThis.mcpTools.someTool(args);
}
throw new Error("MCP tool not available");
} catch (error) {
console.log("MCP failed, using local:", error);
return localImplementation(args);
}
}Testing Without MCP
The codebase works without MCP tools installed:
- All MCP calls have fallbacks
- Tests use local implementations
- Plugin system tests mock MCP availability
Type Safety
MCP tools are accessed via optional chaining:
globalThis.mcpTools?.toolName?.(args)This prevents runtime errors when MCP tools aren't loaded.
Troubleshooting
MCP Tools Not Available
If you see "MCP tool not available" messages:
- Check MCP server configuration in OpenCode
- Verify
globalThis.mcpToolsis populated - Check MCP server logs for errors
- Ensure MCP tools are registered
Fallback Always Triggered
If fallbacks always trigger:
- Verify MCP server is running
- Check network connectivity to MCP server
- Review MCP tool registration
- Check OpenCode MCP integration
Performance Issues
If MCP calls are slow:
- Check MCP server performance metrics
- Reduce query complexity (smaller topK, shallower depth)
- Enable query caching in MCP configuration
- Consider batching multiple queries