Skip to content

[ADX-200] MCP commands#1034

Draft
SharangC96 wants to merge 1 commit into
masterfrom
mcp-commands
Draft

[ADX-200] MCP commands#1034
SharangC96 wants to merge 1 commit into
masterfrom
mcp-commands

Conversation

@SharangC96
Copy link
Copy Markdown
Contributor

Why

How

Tests

Notes

@SharangC96 SharangC96 changed the title mcp commands [ADX-200] MCP commands May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 61%
clarifai.cli.templates 67%
clarifai.cli.templates.toolkits 100%
clarifai.client 64%
clarifai.client.auth 67%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 69%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.rag 0%
clarifai.runners 52%
clarifai.runners.models 61%
clarifai.runners.pipeline_steps 45%
clarifai.runners.pipelines 77%
clarifai.runners.utils 61%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 62%
clarifai.utils.evaluation 16%
clarifai.workflows 95%
examples 64%
Summary 61% (12570 / 20737)

Minimum allowed line rate is 50%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mcp as a lazily loaded top-level CLI command and add it to clarifai --help section ordering.
  • Introduce clarifai mcp commands (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 thread clarifai/cli/mcp.py
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 thread clarifai/cli/mcp.py
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 thread clarifai/cli/mcp.py
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 thread clarifai/cli/base.py
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']),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants