|
| 1 | +--- |
| 2 | +title: Code Utils MCP |
| 3 | +sidebar_label: codebolt.code_utils |
| 4 | +sidebar_position: 21 |
| 5 | +--- |
| 6 | + |
| 7 | +# codebolt.code_utils |
| 8 | + |
| 9 | +Code analysis and utility functions for processing and understanding code structures. |
| 10 | + |
| 11 | +## Available Tools |
| 12 | + |
| 13 | +- `code_utils_get_files_markdown` - Get files content in markdown format |
| 14 | +- `code_utils_get_js_tree` - Get JavaScript/TypeScript AST tree |
| 15 | +- `code_utils_perform_match` - Perform pattern matching on code |
| 16 | +- `code_utils_get_matcher_list` - Get list of available matchers |
| 17 | +- `code_utils_get_match_detail` - Get detailed match information |
| 18 | + |
| 19 | +## Sample Usage |
| 20 | + |
| 21 | +```javascript |
| 22 | +// Get files content in markdown format |
| 23 | +const markdownResult = await codeboltMCP.executeTool( |
| 24 | + "codebolt.code_utils", |
| 25 | + "code_utils_get_files_markdown", |
| 26 | + { |
| 27 | + files: ["src/index.js", "src/utils.js"], |
| 28 | + includeLineNumbers: true, |
| 29 | + syntax: "javascript" |
| 30 | + } |
| 31 | +); |
| 32 | + |
| 33 | +// Get JavaScript AST tree |
| 34 | +const astResult = await codeboltMCP.executeTool( |
| 35 | + "codebolt.code_utils", |
| 36 | + "code_utils_get_js_tree", |
| 37 | + { |
| 38 | + filePath: "src/components/Button.tsx", |
| 39 | + includeComments: true, |
| 40 | + includeLocations: true |
| 41 | + } |
| 42 | +); |
| 43 | + |
| 44 | +// Perform pattern matching on code |
| 45 | +const matchResult = await codeboltMCP.executeTool( |
| 46 | + "codebolt.code_utils", |
| 47 | + "code_utils_perform_match", |
| 48 | + { |
| 49 | + pattern: "function.*\\(", |
| 50 | + files: ["src/**/*.js"], |
| 51 | + matchType: "regex" |
| 52 | + } |
| 53 | +); |
| 54 | + |
| 55 | +// Get list of available matchers |
| 56 | +const matchersResult = await codeboltMCP.executeTool( |
| 57 | + "codebolt.code_utils", |
| 58 | + "code_utils_get_matcher_list", |
| 59 | + { |
| 60 | + category: "javascript", |
| 61 | + includeDescriptions: true |
| 62 | + } |
| 63 | +); |
| 64 | + |
| 65 | +// Get detailed match information |
| 66 | +const detailResult = await codeboltMCP.executeTool( |
| 67 | + "codebolt.code_utils", |
| 68 | + "code_utils_get_match_detail", |
| 69 | + { |
| 70 | + matchId: "match-123", |
| 71 | + includeContext: true, |
| 72 | + contextLines: 5 |
| 73 | + } |
| 74 | +); |
| 75 | + |
| 76 | +// Advanced code analysis |
| 77 | +const analysisResult = await codeboltMCP.executeTool( |
| 78 | + "codebolt.code_utils", |
| 79 | + "code_utils_get_js_tree", |
| 80 | + { |
| 81 | + filePath: "src/api/auth.js", |
| 82 | + analysis: { |
| 83 | + extractFunctions: true, |
| 84 | + extractClasses: true, |
| 85 | + extractImports: true, |
| 86 | + extractExports: true |
| 87 | + } |
| 88 | + } |
| 89 | +); |
| 90 | +``` |
| 91 | + |
| 92 | +:::info |
| 93 | +This functionality is similar to the [codeutils API](/docs/api/apiaccess/codeutils) and provides code analysis through MCP interface. |
| 94 | +::: |
0 commit comments