MCP and LSP integrations
The monkey binary can run as:
- An MCP (Model Context Protocol) server
- A minimal language server (LSP)
Both speak over stdio and are dependency-free wrappers around the same
monkey-* crates the CLI uses.
MCP server
monkey mcp
Speaks newline-delimited JSON-RPC (2024-11-05). Methods:
initializenotifications/initializedtools/listtools/call
Point any MCP client at it:
{
"mcpServers": {
"monkey": { "command": "monkey", "args": ["mcp"] }
}
}
Available tools:
| Tool | What it does |
|---|---|
lint_source |
Lint source text; path picks .mc vs .jungle rules |
lint_file |
Lint a file on disk |
parse_source |
Monkey C lexical/syntax diagnostics (LEX*/PARSE*) |
format_source |
Format source text (same rules as monkey format) |
project_info |
Discover monkey.jungle + manifest.xml and describe it |
sdk_info |
SDK, developer key, and device discovery summary |
device_list |
Connect IQ device profiles (id, name, resolution) |
build_project |
Compile a PRG via monkey build (SDK + key auto-detected) |
run_project |
Build + deploy to the simulator via monkey run |
Diagnostics come back as the same JSON array monkey lint --json emits.
Language server
monkey lsp
Speaks LSP over stdio with full document sync.
Beyond publishing lint diagnostics (textDocument/publishDiagnostics —
parse errors plus every monkey-linter rule, honoring monkey-ignore), it
serves:
textDocument/documentSymbol— class/method/field/enum outlinetextDocument/hover— declaration signatures in markdowntextDocument/definition— same-file go-to-definitiontextDocument/references— same-file find-referencestextDocument/completion— keywords + declared namestextDocument/formatting— full-document format viamonkey-formattertextDocument/rename— project-wide rename (declaration + all uses)textDocument/signatureHelp— call parameter infotextDocument/prepareRename— rename validation- Member completion after
X.via declared types; project-wide symbols
All ranges use UTF-16 positions per the LSP spec.
Configure your editor to launch monkey lsp as the Monkey C language
server:
- VS Code — the bundled extension does this automatically via
vscode-languageclient(monkeyC.cliPath,monkeyC.lspEnabled) and falls back to a persistentmonkey lint --serveprocess when the LSP can't start. - Zed — the bundled extension registers
monkey-lsp; setlsp.monkey.binaryin settings.json (see the Zed extension README).
Suppressing diagnostics
Both paths honor monkey-ignore comments and lint.* keys in
monkey.jungle (lint.disable, lint.severity.<rule>):
var radius = 5; // monkey-ignore unused-variable
// monkey-ignore
var draft = compute(); // whole-line comment covers the next line
Use monkey-ignore alone to suppress everything on the line (or next line),
or list codes: // monkey-ignore unused-variable,PARSE001.