[ADX-200] MCP commands#1034
Draft
SharangC96 wants to merge 1 commit into
Draft
Conversation
Minimum allowed line rate is |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new top-level clarifai mcp CLI command group to provide MCP-focused shortcuts over the existing model init/deploy/list flows, and wires it into the CLI’s lazy-loading + help sectioning so it appears as a first-class command.
Changes:
- Register
mcpas a lazily loaded top-level CLI command and add it toclarifai --helpsection ordering. - Introduce
clarifai mcpcommands (init,deploy,list) that delegate to existing model machinery and print an MCP endpoint URL after deploy. - Update the MCP model template scaffold (FastMCP initialization) and adjust
model init“next steps” messaging for MCP.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
clarifai/utils/cli.py |
Adds mcp to the lazy command mapping and primary help list so the module is auto-imported on demand. |
clarifai/cli/templates/model_templates.py |
Updates the MCP scaffold template (FastMCP server initialization). |
clarifai/cli/model.py |
Updates init success output to point MCP scaffolds toward clarifai mcp deploy. |
clarifai/cli/mcp.py |
New MCP-focused CLI group implementing init, deploy, and list wrappers plus endpoint printing. |
clarifai/cli/base.py |
Adds mcp to top-level CLI help sections. |
Comment on lines
+4
to
+5
| list-models so MCP tool builders get an opinionated, friendly surface | ||
| without losing access to the general-purpose `model` commands. |
Comment on lines
+105
to
+110
| compute = cfg.setdefault('compute', {}) | ||
| # Only override the template's GPU default; respect any explicit user choice. | ||
| if compute.get('instance') in (None, '', 'g5.xlarge'): | ||
| compute['instance'] = 't3a.2xlarge' | ||
| with open(config_path, 'w') as f: | ||
| yaml.safe_dump(cfg, f, sort_keys=False) |
Comment on lines
+23
to
+82
| @cli.group( | ||
| ['mcp'], | ||
| cls=AliasedGroup, | ||
| context_settings={'max_content_width': shutil.get_terminal_size().columns - 10}, | ||
| ) | ||
| def mcp(): | ||
| """Build, deploy, and manage MCP (Model Context Protocol) servers. | ||
|
|
||
| \b | ||
| Workflow: init → (model serve) → deploy → list | ||
|
|
||
| \b | ||
| MCP servers are models under the hood. These commands are opinionated | ||
| shortcuts. For everything else, use the full model engine: | ||
|
|
||
| \b | ||
| clarifai model serve # local testing | ||
| clarifai model upload # upload without deploying | ||
| clarifai model logs # stream deployment logs | ||
| clarifai model status # check deployment health | ||
| clarifai model undeploy # tear down a deployment | ||
| clarifai model list # list all models (not just MCP) | ||
| """ | ||
|
|
||
|
|
||
| @mcp.command() | ||
| @click.argument("model_path", type=click.Path(), required=False, default=None) | ||
| @click.pass_context | ||
| def init(ctx, model_path): | ||
| """Scaffold a new MCP server project. | ||
|
|
||
| \b | ||
| Creates a ready-to-use MCP server directory with everything needed | ||
| to define tools, resources, and prompts — then serve or deploy them. | ||
|
|
||
| \b | ||
| MODEL_PATH Project directory name or path (default: current directory). | ||
|
|
||
| \b | ||
| Examples: | ||
| clarifai mcp init my-search-tool | ||
| clarifai mcp init # scaffold in current directory | ||
|
|
||
| \b | ||
| Next steps: | ||
| clarifai model serve ./my-search-tool # test locally | ||
| clarifai mcp deploy ./my-search-tool # deploy to Clarifai | ||
| """ | ||
| # Defer import to avoid cycles and to honor the lazy-loading pattern. | ||
| from clarifai.cli.model import init as model_init | ||
|
|
||
| ctx.invoke( | ||
| model_init, | ||
| model_path=model_path, | ||
| toolkit='mcp', | ||
| model_name=None, | ||
| streaming_video=False, | ||
| ) | ||
|
|
||
| _apply_mcp_compute_defaults(model_path) |
Comment on lines
733
to
739
| ('Auth', ['login', 'whoami', 'logout']), | ||
| ('Config', ['config']), | ||
| ('Models', ['model']), | ||
| ('MCP', ['mcp']), | ||
| ('Skills', ['skills']), | ||
| ('Pipelines', ['pipeline', 'pipelinestep', 'pipelinerun', 'pipelinetemplate']), | ||
| ('Compute', ['list-instances', 'computecluster', 'nodepool', 'deployment']), |
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.
Why
How
Tests
Notes