6.5. MCP Server — AI Tool Integration
The daslang MCP server exposes 28 compiler-backed tools to AI coding assistants via the Model Context Protocol. It provides compilation diagnostics, type inspection, go-to-definition, find-references, AST dump, AOT generation, expression evaluation, parse-aware grep, and more.
Uses stdio transport – no extra build dependencies.
6.5.1. Quick start
Test the server manually:
# Windows
bin/Release/daslang.exe utils/mcp/main.das
# Linux
./bin/daslang utils/mcp/main.das
Configure in .mcp.json (project root):
{
"mcpServers": {
"daslang": {
"command": "bin/Release/daslang.exe",
"args": ["utils/mcp/main.das"]
}
}
}
Or add via CLI:
claude mcp add daslang -- bin/Release/daslang.exe utils/mcp/main.das
Claude Code starts and stops the server automatically with each session.
6.5.2. Tools
The server exposes 28 tools. Each tool is invoked via MCP’s
tools/call method.
6.5.2.1. Compilation and diagnostics
Tool |
Description |
|---|---|
|
Compile a |
|
Compile a |
|
Compile a |
|
Compile a |
|
List all available daslang modules (builtin C++ modules and
daslib). Optional |
|
List all functions, types, enums, and globals exported by a
builtin or daslib module. Optional |
6.5.2.3. Program introspection
Tool |
Description |
|---|---|
|
Dump AST of an expression or compiled function.
|
|
Produce full post-compilation program text (like
|
|
Describe a type’s fields, methods, values, and base type. Supports structs, classes, handled types, enums, bitfields, variants, tuples, typedefs. |
6.5.2.4. Execution
Tool |
Description |
|---|---|
|
Run a |
|
Run dastest on a |
|
Evaluate a daslang expression and return its printed result.
Supports module imports via |
6.5.2.5. Code generation and transformation
Tool |
Description |
|---|---|
|
Format a |
|
Convert a |
|
Generate AOT (ahead-of-time) C++ code for a |
6.5.2.6. Parse-aware search (tree-sitter)
Tool |
Description |
|---|---|
|
Parse-aware symbol search across |
|
List all declarations in a file or set of files using
tree-sitter. Works on broken/incomplete code – no compilation
needed. Conditional on |
6.5.2.7. Live-reload control
These tools interact with a running daslang-live
instance via its REST API. All accept an optional port parameter
(default 9090).
Tool |
Description |
|---|---|
|
Launch |
|
Query the running instance for fps, uptime, paused state, and error status. |
|
Retrieve the last compilation error (plain text). |
|
Trigger an incremental or full reload. |
|
Pause or unpause execution. |
|
Dispatch a |
|
Gracefully shut down the running instance. |
6.5.3. ast-grep / tree-sitter setup
The grep_usage and outline tools use
ast-grep (sg CLI) with a custom
tree-sitter grammar for daslang. The sgconfig.yml config file is
platform-specific (shared library extension differs), so it is
gitignored.
Copy the appropriate template to sgconfig.yml in the project root:
# Windows
cp sgconfig.yml.windows sgconfig.yml
# Linux
cp sgconfig.yml.linux sgconfig.yml
# macOS
cp sgconfig.yml.osx sgconfig.yml
6.5.4. Architecture
Each tool invocation runs in a separate thread with its own context/heap – when the thread ends, its memory is freed without GC.
Protocol logic lives in
protocol.das, the entry point ismain.das.Heap is collected after each request when over threshold (1 MB).
Tool handlers are modular: each tool lives in
tools/*.das, shared utilities intools/common.das.
6.5.5. Protocol
The server implements MCP via JSON-RPC 2.0 over stdio:
Reads newline-delimited JSON (NDJSON) from stdin.
Writes JSON-RPC responses to stdout (one line per message).
Handles:
initialize,tools/list,tools/call,ping.Logs to stderr and to
utils/mcp/mcp_server.log.File paths passed to tools are resolved relative to the server’s working directory.
6.5.6. Configuring Claude Code permissions
Optionally, allow all MCP tools without prompting by adding to
.claude/settings.json:
{
"permissions": {
"allow": [
"mcp__daslang__compile_check",
"mcp__daslang__list_functions",
"mcp__daslang__list_types",
"mcp__daslang__run_test",
"mcp__daslang__format_file",
"mcp__daslang__run_script",
"mcp__daslang__ast_dump",
"mcp__daslang__list_modules",
"mcp__daslang__find_symbol",
"mcp__daslang__list_requires",
"mcp__daslang__list_module_api",
"mcp__daslang__convert_to_gen2",
"mcp__daslang__goto_definition",
"mcp__daslang__type_of",
"mcp__daslang__find_references",
"mcp__daslang__program_log",
"mcp__daslang__eval_expression",
"mcp__daslang__describe_type",
"mcp__daslang__grep_usage",
"mcp__daslang__outline",
"mcp__daslang__aot"
]
}
}
See also
utils/mcp/README.md – setup and configuration details
Model Context Protocol specification
utils_daslang_live – the live-reload application host controlled by live_* tools