Commit 9dcddee
committed
feat: Implement MCP code generation crate for TypeScript/Python wrappers
This commit implements Phase 1 of the Code Execution with MCP plan,
creating the terraphim_mcp_codegen crate that generates typed wrappers
for MCP tools to enable code-based tool usage instead of direct tool calls.
New crate features:
- terraphim_mcp_codegen: Code generation infrastructure
- Tool introspection and metadata extraction
- TypeScript code generator with full type definitions
- Python code generator with type hints
- MCP runtime bridge for JavaScript and Python
- CLI tool (mcp-codegen) for generating code packages
Generated code includes:
- Typed interfaces/classes for all 17 MCP tools
- Async/await patterns for tool calls
- JSDoc/docstring documentation
- Usage examples for each tool
- Tool categorization and capability metadata
This enables AI agents to write code that imports MCP tools as modules:
```typescript
import { terraphim } from 'mcp-servers';
const results = await terraphim.search({ query: "rust patterns" });
const filtered = results.filter(r => r.rank > 0.8);
return { count: filtered.length, top: filtered[0] };
```
Expected outcome: 98% token reduction (150K → 2K tokens for workflows)1 parent 0f376b7 commit 9dcddee
8 files changed
Lines changed: 2269 additions & 4 deletions
File tree
- crates/terraphim_mcp_codegen
- src
- bin
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments