Repository navigation
feat(mcp): add first-class artifact list tool #4867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,830
−16
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df5e416
feat(mcp): add artifact list tool
mnriem 280bf59
fix(mcp): bound artifact list responses
mnriem c18ef28
fix(mcp): bound artifact list wire responses
mnriem 1fa5ce1
fix(mcp): harden artifact list contracts
mnriem c1c5aeb
fix(mcp): bound artifact list error responses
mnriem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| """MCP registration and inventory for the ``specify artifact`` hierarchy.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
| from typing import Literal | ||
|
|
||
| from mcp.server import MCPServer | ||
|
|
||
| from ._operation_list import ARTIFACT_LIST_OPERATION | ||
| from .mcp_list import register as register_list | ||
|
|
||
| ArtifactOperationId = Literal["artifact.list", "artifact.info", "artifact.lookup"] | ||
| ArtifactCliPath = Literal[ | ||
| "specify artifact list", | ||
| "specify artifact info", | ||
| "specify artifact lookup", | ||
| ] | ||
| ArtifactToolName = Literal[ | ||
| "specify_artifact_list", | ||
| "specify_artifact_info", | ||
| "specify_artifact_lookup", | ||
| ] | ||
| ArtifactDisposition = Literal["available", "unavailable"] | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ArtifactToolInventory: | ||
| """One authoritative MCP disposition for an artifact CLI leaf.""" | ||
|
|
||
| operation_id: ArtifactOperationId | ||
| cli_path: ArtifactCliPath | ||
| mcp_tool_name: ArtifactToolName | ||
| contract_version: str | None | ||
| disposition: ArtifactDisposition | ||
| disposition_reason: str | None | ||
| capabilities: frozenset[Literal["local-read"]] | ||
| network_access: Literal["none"] | ||
|
|
||
|
|
||
| ARTIFACT_TOOLS = ( | ||
| ArtifactToolInventory( | ||
| operation_id=ARTIFACT_LIST_OPERATION.operation_id, | ||
| cli_path="specify artifact list", | ||
| mcp_tool_name="specify_artifact_list", | ||
| contract_version=ARTIFACT_LIST_OPERATION.contract_version, | ||
| disposition="available", | ||
| disposition_reason=None, | ||
| capabilities=ARTIFACT_LIST_OPERATION.capabilities, | ||
| network_access=ARTIFACT_LIST_OPERATION.network_access, | ||
| ), | ||
| ArtifactToolInventory( | ||
| operation_id="artifact.info", | ||
| cli_path="specify artifact info", | ||
| mcp_tool_name="specify_artifact_info", | ||
| contract_version=None, | ||
| disposition="unavailable", | ||
| disposition_reason=( | ||
| "The artifact.info CLI leaf does not yet have a shared typed operation." | ||
| ), | ||
| capabilities=frozenset({"local-read"}), | ||
| network_access="none", | ||
| ), | ||
| ArtifactToolInventory( | ||
| operation_id="artifact.lookup", | ||
| cli_path="specify artifact lookup", | ||
| mcp_tool_name="specify_artifact_lookup", | ||
| contract_version=None, | ||
| disposition="unavailable", | ||
| disposition_reason=( | ||
| "The artifact.lookup CLI leaf does not yet have a shared typed operation." | ||
| ), | ||
| capabilities=frozenset({"local-read"}), | ||
| network_access="none", | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def register(server: MCPServer, *, launch_directory: Path) -> None: | ||
| """Register every available artifact tool from the explicit inventory.""" | ||
| available = { | ||
| item.operation_id: item | ||
| for item in ARTIFACT_TOOLS | ||
| if item.disposition == "available" | ||
| } | ||
| list_tool = available[ARTIFACT_LIST_OPERATION.operation_id] | ||
| register_list( | ||
| server, | ||
| launch_directory=launch_directory, | ||
| tool_name=list_tool.mcp_tool_name, | ||
| ) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.