Skip to content

Commit b6acc14

Browse files
Expose advanced query and incremental analysis features in MCP server
Add 10 new MCP tools to expose existing Goblint server capabilities: - merge_config, read_config: Additional configuration options - get_files, get_varinfos: File and variable information queries - get_cfg, cfg_lookup: Control flow graph queries - arg_lookup, arg_eval, arg_eval_int: ARG node queries and evaluation - global_state: Global state queries This addresses the request to expose complex queries and incremental analysis features from the standard Goblint server mode via MCP. Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
1 parent 149a1df commit b6acc14

2 files changed

Lines changed: 465 additions & 2 deletions

File tree

docs/user-guide/mcp-server.md

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,144 @@ Query the analysis state at a specific program location.
198198
}
199199
```
200200

201+
#### 8. merge_config
202+
203+
Merge JSON configuration into current Goblint configuration.
204+
205+
**Input Schema:**
206+
```json
207+
{
208+
"config": "object"
209+
}
210+
```
211+
212+
#### 9. read_config
213+
214+
Read and merge configuration from a file.
215+
216+
**Input Schema:**
217+
```json
218+
{
219+
"file": "string"
220+
}
221+
```
222+
223+
#### 10. get_files
224+
225+
Get list of files that were analyzed, including dependencies.
226+
227+
**Input Schema:**
228+
```json
229+
{}
230+
```
231+
232+
**Returns:** JSON object with file dependency information.
233+
234+
#### 11. get_varinfos
235+
236+
Get information about all variables in the analyzed code.
237+
238+
**Input Schema:**
239+
```json
240+
{}
241+
```
242+
243+
**Returns:** JSON array with variable information including vid, name, type, location, role (formal/local/function/global), and function context.
244+
245+
#### 12. get_cfg
246+
247+
Get control flow graph (CFG) for a specific function in DOT format.
248+
249+
**Input Schema:**
250+
```json
251+
{
252+
"function": "string"
253+
}
254+
```
255+
256+
**Returns:** CFG in DOT graph format for visualization.
257+
258+
#### 13. cfg_lookup
259+
260+
Look up CFG node information by node ID or location.
261+
262+
**Input Schema:**
263+
```json
264+
{
265+
"node": "string (optional)",
266+
"location": {
267+
"file": "string",
268+
"line": "integer",
269+
"column": "integer"
270+
} "(optional)"
271+
}
272+
```
273+
274+
**Returns:** Node information including location, function, and adjacent nodes.
275+
276+
#### 14. arg_lookup
277+
278+
Look up ARG (Abstract Reachability Graph) node information.
279+
280+
**Input Schema:**
281+
```json
282+
{
283+
"node": "string (optional)",
284+
"cfg_node": "string (optional)",
285+
"location": {
286+
"file": "string",
287+
"line": "integer",
288+
"column": "integer"
289+
} "(optional)"
290+
}
291+
```
292+
293+
**Returns:** ARG node information with edges and context.
294+
295+
#### 15. arg_eval
296+
297+
Evaluate an expression at a specific ARG node.
298+
299+
**Input Schema:**
300+
```json
301+
{
302+
"node": "string",
303+
"expression": "string (optional)",
304+
"vid": "integer (optional)"
305+
}
306+
```
307+
308+
**Note:** Provide either `expression` (C expression string) or `vid` (variable ID), not both.
309+
310+
#### 16. arg_eval_int
311+
312+
Evaluate an integer expression at a specific ARG node.
313+
314+
**Input Schema:**
315+
```json
316+
{
317+
"node": "string",
318+
"expression": "string"
319+
}
320+
```
321+
322+
**Returns:** Integer value with raw, int, and bool representations.
323+
324+
#### 17. global_state
325+
326+
Query global state for a variable or at a specific node.
327+
328+
**Input Schema:**
329+
```json
330+
{
331+
"vid": "integer (optional)",
332+
"node": "string (optional)"
333+
}
334+
```
335+
336+
**Note:** Provide at most one of `vid` or `node`.
337+
338+
201339
## Integration with LLM Frameworks
202340

203341
### Claude Desktop
@@ -286,9 +424,8 @@ To enable debug logging, configure Goblint before analyzing:
286424

287425
## Limitations
288426

289-
- The MCP server currently supports a subset of Goblint's full functionality
290-
- Complex queries and incremental analysis features from the standard Goblint server mode are not yet exposed via MCP
291427
- Large projects may take significant time to analyze
428+
- Some advanced incremental analysis features may require specific configuration
292429

293430
## See Also
294431

0 commit comments

Comments
 (0)