package PBS references and expose paginated MCP reads
This commit is contained in:
@@ -19,6 +19,16 @@ public final class McpProjectKnowledgeTools {
|
||||
var paths = new SimpleModule().addSerializer(Path.class, new ToStringSerializer());
|
||||
var wireMapper = mapper.copy().registerModule(paths);
|
||||
return Map.of("studio_project_context", arguments -> McpToolResult.success(mapper,
|
||||
wireMapper.valueToTree(knowledge.context(Path.of(arguments.path("projectRoot").asText())))));
|
||||
wireMapper.valueToTree(knowledge.context(Path.of(arguments.path("projectRoot").asText())))),
|
||||
"studio_reference_read", arguments -> McpToolResult.success(mapper, wireMapper.valueToTree(
|
||||
knowledge.readReference(Path.of(arguments.path("projectRoot").asText()), arguments.path("referenceId").asText(),
|
||||
integer(arguments, "offset", 0), integer(arguments, "limit", 4000)))));
|
||||
}
|
||||
|
||||
private static int integer(JsonNode arguments, String name, int fallback) {
|
||||
var value = arguments.get(name);
|
||||
if (value == null) return fallback;
|
||||
if (!value.isIntegralNumber() || !value.canConvertToInt()) throw new IllegalArgumentException("Invalid " + name);
|
||||
return value.intValue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user