Add MCP server to AST tool

Integrates the MCP server functionality into the AST tool binary. This
allows the tool to act as a server for LLM integration, enabling
communication over stdio. The server can list available bindings and
execute scripts.
This commit is contained in:
2026-03-25 14:03:22 +01:00
parent 6042415dfc
commit 641a19e736
6 changed files with 386 additions and 2 deletions
+13
View File
@@ -600,6 +600,19 @@ impl Environment {
}
/// Returns the names of all bindings registered in the fixed RTL scope.
/// Useful for introspection (e.g., MCP server listing available built-ins).
pub fn list_bindings(&self) -> Vec<String> {
let root_scopes = self.root_scopes.borrow();
let mut names: Vec<String> = root_scopes[0]
.locals
.keys()
.map(|sym| sym.name.to_string())
.collect();
names.sort();
names
}
pub fn dump_ast(&self, source: &str) -> Result<String, String> {
self.preload_dependencies(source, None)?;
let compiled = self.compile(source).into_result()?;