feat(mcp): per-repository ai-instructions endpoint#732
Merged
Conversation
Add GET /api/restify/{repository}/ai-instructions returning a
client-agnostic markdown document describing every MCP-enabled tool of a
repository (CRUD + actions + getters) with its description and input
parameters (required/optional/type).
Built entirely on the existing MCP pipeline (McpTools::getRepositoryOperations
+ getOperationDetails), so the output cannot drift from what the MCP server
actually exposes. Repository-level authorization is enforced via the normal
RestifyRequest::repository() resolution; per-tool visibility/permission
filtering is inherited from MCP discovery.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR Summary
|
The repository-level ai-instructions endpoint reuses the existing MCP pipeline (McpTools::getRepositoryOperations + getOperationDetails), so the per-action helper added earlier is no longer used by anything: - remove Action::toMcpInvocationDescriptor() + buildRoute() - delete McpInvocationDescriptor and BuildMcpExamplePayloadAction + tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a built-in, auto-registered Restify endpoint:
It returns a client-agnostic markdown document describing every MCP-enabled tool of a repository — CRUD (index/show/store/update/delete as enabled) + actions + getters — each with its description and input parameters (required/optional/type). This is the "copy for AI" / "copy for LLM" source: paste it into any agent so it knows exactly which MCP tools the resource exposes and how to call them.
Why
Per review feedback on the growee side: the "copy for AI" helper belongs in Restify, at the repository level, not as per-action custom app code. It must rely fully on Restify's own schema generation so it can never drift from what the MCP server actually exposes.
How
RepositoryAiInstructionsRendererbuilds the markdown entirely from the existing MCP pipeline —McpTools::getRepositoryOperations()(enumerates all tools) +McpTools::getOperationDetails()(per-tool schema), wrapping each schema withJsonSchemaTypeFactory->object()exactly likeWrapperToolHelpers::formatSchemaForDisplay(). No new schema/enumeration logic.RepositoryAiInstructionsControllerresolves + authorizes the repository via the normalRestifyRequest::repository()flow (allowRestifypolicy). Unknown / non-MCP repositories → 404; unauthorized tool access → 403.RoutesDefinitionbefore the CRUD{repositoryId}route soai-instructionsis not captured as a resource id (same placement strategy as/actionsand/getters).Output shape
Tests
tests/MCP/RepositoryAiInstructionsTest.php:HasMcpTools→ 404Full
tests/MCPsuite green (53 tests). Pint clean.🤖 Generated with Claude Code