expose manifest-driven project knowledge through MCP
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package p.studio.app.mcp;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import p.studio.api.automation.ProjectKnowledge;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/** Context reads need authentication at transport level, but no control grant or task. */
|
||||
public final class McpProjectKnowledgeTools {
|
||||
private McpProjectKnowledgeTools() {}
|
||||
|
||||
public static Map<String, Function<JsonNode, McpToolResult>> handlers(ProjectKnowledge knowledge, ObjectMapper mapper) {
|
||||
// Jackson's default Path serializer produces file: URIs; the public contract uses absolute paths.
|
||||
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())))));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user