Skip to content
Back to search

code-to-tree

A runtime-free MCP server that converts source code into AST🌲, regardless of language.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/micl2e2--code-to-tree/badge.svg)](/listings/micl2e2--code-to-tree)

HTML

<a href="/listings/micl2e2--code-to-tree"><img src="/api/listings/micl2e2--code-to-tree/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 224 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Table of Contents
  2. - [MCP Server: code-to-tree](#orgf542482)
  3. - [Using code-to-tree](#org862e7dc)
  4. - [Configure MCP Clients](#orge54fa87)
  5. - [Building (Windows)](#org48a8180)
  6. - [Building (macOS)](#orgbaa740e)
  7. <a id="orgf542482"></a>
  8. # MCP Server: code-to-tree
  9. The code-to-tree server's goals are:
  10. 1. Give LLMs the capability of **accurately** converting source code into
  11. AST(Abstract Syntax Tree), regardless of language.
  12. 2. One **standalone** binary should be everything the MCP client needs.
  13. These goals imply:
  14. 1. The underlying syntax parser should be **versatile** enough. Here we
  15. choose [tree-sitter](https://github.com/tree-sitter/tree-sitter), and languages are: C, C++, Rust, Ruby, Go, Java, Python.
  16. 2. The server should be able to carry all capabilities within
  17. itself, imposing **minimum** software dependencies on the end user's
  18. machine. Here we choose [mcpc](https://github.com/micl2e2/mcpc).
  19. **Screenshots:**
  20. <img src="./chathistory.png" width="450px" /><img src="./wholeast.png" width="200px" />
  21. The above screenshots are obtained by asking the question specified
  22. in `q.md`.
  23. (**IMPORTANT NOTE**: LLMs have no responsibility of generating the identical
  24. result for the same question, you will likely get a completely different
  25. style or content. The screenshots or questions provided here are just for the reference)
  26. <a href="https://glama.ai/mcp/servers/@micl2e2/code-to-tree">
  27. <img width="380" height="200" src="https://glama.ai/mcp/servers/@micl2e2/code-to-tree/badge" alt="code-to-tree MCP server" />
  28. </a>
  29. <a id="org862e7dc"></a>
  30. # Using code-to-tree
  31. Before everthing, you need to have the code-to-tree executable on your
  32. machine (`code-to-tree.exe` for Windows, `code-to-tree` for macOS),
  33. you can download at GitHub release [page](https://github.com/micl2e2/code-to-tree/releases) or build it yourself. Once
  34. downloaded, you configure your MCP clients to install it, check the section
  35. *"Configure MCP Clients"* for more details.
  36. <a id="orge54fa87"></a>
  37. # Configure MCP Clients
  38. Here we use Claude as the example.
  39. ## Windows
  40. In your Claude configuration
  41. (`C:\Users\YOUR_NAME\AppData\Roaming\Claude\claude_desktop_config.json`),
  42. specify the location of `code-to-tree.exe`:
  43. {
  44. "mcpServers": {
  45. "code-to-tree": { "command": "C:\\path\\to\\code-to-tree.exe" }
  46. }
  47. }
  48. ## macOS
  49. In your Claude configuration,
  50. (`~/Library/Application Support/Claude/claude_desktop_config.json`)
  51. specify the location of `code-to-tree`
  52. {
  53. "mcpServers": {
  54. "code-to-tree": { "command": "/path/to/code-to-tree" }
  55. }
  56. }
  57. <a id="org48a8180"></a>
  58. # Building (Windows)
  59. ## 1. Prepare environment
  60. 1. download & install MSYS2.
  61. 2. open application "MSYS2 MINGW64"
  62. 3. run `pacman -S make gcc git`
  63. ## 2. Prepare tree-sitter libraries
  64. Here we need to compile and install tree-sitter and all related grammars.
  65. Clone them:
  66. git clone https://github.com/tree-sitter/tree-sitter
  67. git clone https://github.com/tree-sitter/tree-sitter-c
  68. git clone https://github.com/tree-sitter/tree-sitter-cpp
  69. git clone https://github.com/tree-sitter/tree-sitter-rust
  70. git clone https://github.com/tree-sitter/tree-sitter-ruby
  71. git clone https://github.com/tree-sitter/tree-sitter-go
  72. git clone https://github.com/tree-sitter/tree-sitter-java
  73. Compile and install them:
  74. cd tree-sitter && OS=1 make install
  75. cd tree-sitter-c && OS=1 make install
  76. cd tree-sitter-cpp && OS=1 make install
  77. cd tree-sitter-rust && OS=1 make install
  78. cd tree-sitter-ruby && OS=1 make install
  79. cd tree-sitter-go && OS=1 make install
  80. cd tree-sitter-java && OS=1 make install
  81. ## 3. Build code-to-tree
  82. Install mcpc:
  83. git clone https://github.com/micl2e2/mcpc
  84. cd mcpc && make install
  85. Compile code-to-tree:
  86. cd mcpc/example/code-to-tree
  87. CFLAGS="-I/usr/local/include -L/usr/local/lib" make
  88. # Check the binary
  89. file code-to-tree.exe
  90. # Remember the binary's location
  91. pwd
  92. # Assume the output is: /c/path/to/code-to-tree.exe
  93. <a id="orgbaa740e"></a>
  94. # Building (macOS)
  95. ## 1. Prepare environment
  96. 1. Xcode Command Line Tools
  97. ## 2. Prepare tree-sitter libraries
  98. Here we need to compile and install tree-sitter and all related grammars.
  99. Clone them:
  100. git clone https://github.com/tree-sitter/tree-sitter
  101. git clone https://github.com/tree-sitter/tree-sitter-c
  102. git clone https://github.com/tree-sitter/tree-sitter-cpp
  103. git clone https://github.com/tree-sitter/tree-sitter-rust
  104. git clone https://github.com/tree-sitter/tree-sitter-ruby
  105. git clone https://github.com/tree-sitter/tree-sitter-go
  106. git clone https://github.com/tree-sitter/tree-sitter-java
  107. Compile and install them:
  108. cd tree-sitter && make install
  109. cd tree-sitter-c && make install
  110. cd tree-sitter-cpp && make install
  111. cd tree-sitter-rust && make install
  112. cd tree-sitter-ruby && make install
  113. cd tree-sitter-go && make install
  114. cd tree-sitter-java && make install
  115. ## 3. Build code-to-tree
  116. Install mcpc:
  117. git clone https://github.com/micl2e2/mcpc
  118. cd mcpc && make install
  119. Compile code-to-tree:
  120. cd mcpc/example/code-to-tree
  121. make
  122. # Check the binary
  123. file ./code-to-tree
  124. # Remember the binary's location
  125. pwd
  126. # Assume the output is: /path/to/code-to-tree

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.