feat(mcp): expose language operation discovery contract
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

This commit is contained in:
2026-11-27 01:19:37 +00:00
parent 219969b9e6
commit 82ceb746ad
7 changed files with 643 additions and 35 deletions
@@ -18,6 +18,14 @@ public final class McpConnectionGuide implements AgentConnectionGuide {
Wait for the developer to grant control in DEV, then call studio_control_acquire. Copying or connecting
does not grant permission. Use the returned taskId for all work and operate only on this project.
Edit saved project files with your native tools; SDK and external libraries are read-only.
Discover language operations and required parameters in studio_language_query.inputSchema or
studio_project_context.languageQuery. languages[].capabilities describes provider support, not
operation names: callHierarchy maps to prepareCallHierarchy, incomingCalls and outgoingCalls;
rename maps to prepareRename and rename. The running LSP checks effective support on each call.
Use document URIs, not file paths, and zero-based line/character positions in UTF-16 code units.
Begin call hierarchy with prepareCallHierarchy, then use its returned itemId in the same task/project.
Hierarchy itemIds expire on task release/revocation. definition may return a task-owned read-only
prometeu-source: URI; read it with readExternalSource or continue hover/definition in that task.
Validate saved changes with studio_language_query and studio_build_start. Poll studio_operation_get.
Supply a unique clientRequestId per intended build/advance. Recover lost responses by lookup using
clientRequestId; do not blindly repeat frame advancement with a new ID. Cancellation acknowledgement
@@ -2,6 +2,7 @@ package p.studio.app.mcp;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import p.studio.api.automation.ProjectKnowledge;
@@ -18,8 +19,12 @@ public final class McpProjectKnowledgeTools {
// 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())))),
var catalog = new McpToolCatalog(mapper);
return Map.of("studio_project_context", arguments -> {
ObjectNode context = wireMapper.valueToTree(knowledge.context(Path.of(arguments.path("projectRoot").asText())));
context.set("languageQuery", catalog.languageQueryDescription());
return McpToolResult.success(mapper, context);
},
"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)))));
@@ -39,6 +39,25 @@ public final class McpToolCatalog {
result.remove(List.of("authority", "exampleArguments", "exampleValue"));
return result;
}
/** Shared schema and operation constraints are projected from the advertised contract. */
public ObjectNode languageQueryDescription() {
var definition = (ObjectNode) definition("studio_language_query");
var schema = definition.required("inputSchema");
var result = definition.objectNode().put("tool", "studio_language_query")
.put("description", definition.required("description").asText());
result.set("parametersSchema", schema.required("properties").required("parameters").deepCopy());
var operations = result.putArray("operations");
for (var branch : schema.required("oneOf")) {
var properties = branch.required("properties");
var operation = operations.addObject()
.put("operation", properties.required("operation").required("const").asText())
.put("capability", branch.required("x-studio-capability").asText())
.put("description", branch.required("description").asText());
operation.set("requiredParameters", properties.required("parameters").required("required").deepCopy());
operation.set("parametersSchema", properties.required("parameters").deepCopy());
}
return result;
}
public void validateArguments(String name, JsonNode arguments) {
ContractSchema.validate(definition(name).required("inputSchema"), arguments);
var root = arguments.required("projectRoot").asText();