Skip to content

[ML-59256] Add MCP approval/response classes#18815

Merged
serena-ruan merged 43 commits intomlflow:masterfrom
kevin-wangg:add-tool-confirmation-types
Nov 26, 2025
Merged

[ML-59256] Add MCP approval/response classes#18815
serena-ruan merged 43 commits intomlflow:masterfrom
kevin-wangg:add-tool-confirmation-types

Conversation

@kevin-wangg
Copy link
Contributor

@kevin-wangg kevin-wangg commented Nov 12, 2025

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/18815/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/18815/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/18815/merge

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

  • This PR adds MCP approval and response classes to MLflow

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Manually tested with a MAS agent:
Sent the following request that should trigger a tool call

curl --location 'https://eng-ml-agent-bricks-us-east-1.staging.cloud.databricks.com/serving-endpoints/mas-d477f72c-endpoint/invocations' \
--header 'x-databricks-traffic-id: testenv://liteswap/kevin-mas' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dapi4d06921b973e659b423567eb349e39ff' \
--data '{
    "input": [
        {
            "role": "user",
            "content": "what'\''s 123 x 100"
        },
        {
            "type": "message",
            "id": "run--db6f9559-40e1-4f26-b5c8-3b824d025827",
            "content": [
                {
                    "type": "output_text",
                    "text": "I'\''ll calculate 123 x 100 for you using Python.",
                    "annotations": []
                }
            ],
            "role": "assistant"
        }
    ],
    "databricks_options": {
        "return_trace": true
    },
    "stream": true
}'

Received the following

{
    "type": "response.output_item.done",
    "custom_outputs": null,
    "item": {
        "type": "mcp_approval_request",
        "id": "1da9fbd1-1db2-4b32-a464-e09b613975b5",
        "arguments":"{\"code\": \"result = 123 * 100\\nprint(f\\\"123 \× 100 = {result}\\\")\"}",
        "name": "system__ai__python_exec",
        "server_label": "server_label"
    }
}

Appended the mcp approval request and mcp approval response to the messages, and then sent it back

curl --location 'https://eng-ml-agent-bricks-us-east-1.staging.cloud.databricks.com/serving-endpoints/mas-d477f72c-endpoint/invocations' \
--header 'x-databricks-traffic-id: testenv://liteswap/kevin-mas' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dapi4d06921b973e659b423567eb349e39ff' \
--data '{
    "input": [
        {
            "role": "user",
            "content": "what'\''s 123 x 100"
        },
        {
            "type": "message",
            "id": "run--db6f9559-40e1-4f26-b5c8-3b824d025827",
            "content": [
                {
                    "type": "output_text",
                    "text": "I'\''ll calculate 123 x 100 for you using Python.",
                    "annotations": []
                }
            ],
            "role": "assistant"
        },
        {
            "type": "mcp_approval_request",
            "id": "1234",
            "name": "system__ai__python_exec",
            "arguments": "{\"code\": \"result = 123 * 100\\nprint(f\\\"123 x 100 = {result}\\\")\"}",
            "server_label": "server_label"
        },
        {
            "type": "mcp_approval_response",
            "id": "5678",
            "approval_request_id": "1234",
            "approve": true,
            "reason": "approved"
        } 
    ],
    "databricks_options": {
        "return_trace": true
    },
    "stream": true
}'

Received the following stream back
image

If the MCP approval was denied, then nothing comes back.

curl --location 'https://eng-ml-agent-bricks-us-east-1.staging.cloud.databricks.com/serving-endpoints/mas-d477f72c-endpoint/invocations' \
--header 'x-databricks-traffic-id: testenv://liteswap/kevin-mas' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer dapi4d06921b973e659b423567eb349e39ff' \
--data '{
    "input": [
        {
            "role": "user",
            "content": "what'\''s 123 x 100"
        },
        {
            "type": "message",
            "id": "run--db6f9559-40e1-4f26-b5c8-3b824d025827",
            "content": [
                {
                    "type": "output_text",
                    "text": "I'\''ll calculate 123 x 100 for you using Python.",
                    "annotations": []
                }
            ],
            "role": "assistant"
        },
        {
            "type": "mcp_approval_request",
            "id": "1234",
            "name": "system__ai__python_exec",
            "arguments": "{\"code\": \"result = 123 * 100\\nprint(f\\\"123 x 100 = {result}\\\")\"}",
            "server_label": "server_label"
        },
        {
            "type": "mcp_approval_response",
            "id": "5678",
            "approval_request_id": "1234",
            "approve": false,
            "reason": "disapproved"
        }  
    ],
    "databricks_options": {
        "return_trace": true
    },
    "stream": true
}'

Receive back
image

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.

What is a minor/patch release?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

@github-actions
Copy link
Contributor

@kevin-wangg Thank you for the contribution! Could you fix the following issue(s)?

⚠ DCO check

The DCO check failed. Please sign off your commit(s) by following the instructions here. See https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.md#sign-your-work for more details.

Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
@kevin-wangg kevin-wangg force-pushed the add-tool-confirmation-types branch from 40b3d2e to 09095f2 Compare November 12, 2025 22:18
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
@kevin-wangg kevin-wangg changed the title Add MCP approval/response classes [ML-59256] Add MCP approval/response classes Nov 13, 2025
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
@kevin-wangg kevin-wangg force-pushed the add-tool-confirmation-types branch from a471b9b to 66a7267 Compare November 20, 2025 22:40
@github-actions github-actions bot added v3.6.1 rn/none List under Small Changes in Changelogs. area/models MLmodel format, model serialization/deserialization, flavors labels Nov 20, 2025
kevin-wangg and others added 7 commits November 21, 2025 01:30
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
…cessing (mlflow#18898)

Signed-off-by: Avesh Singh <aveshcsingh@gmail.com>
Co-authored-by: Xiang Shen <xshen.shc@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
…18937)

Signed-off-by: Kevin Lin <kevin.lin@databricks.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
Co-authored-by: Yuki Watanabe <31463517+B-Step62@users.noreply.github.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
…8948)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
@kevin-wangg kevin-wangg force-pushed the add-tool-confirmation-types branch from 1ed3fa7 to b4c4562 Compare November 21, 2025 09:30
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Copy link
Collaborator

@bbqiu bbqiu left a comment

Choose a reason for hiding this comment

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

changes LGTM - please wait on merging until you have had a chance to test it w/ an agent manually?

Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
Copy link
Collaborator

@serena-ruan serena-ruan left a comment

Choose a reason for hiding this comment

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

LGTM! @bbqiu could we file a follow-up PR to clean up the static methods in ResponsesAgent?

Signed-off-by: Kevin Wang <kevinwang2040@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

Documentation preview for 3793317 is available at:

Changed Pages (1)

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

@serena-ruan serena-ruan merged commit 78fb007 into mlflow:master Nov 26, 2025
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/models MLmodel format, model serialization/deserialization, flavors rn/none List under Small Changes in Changelogs. v3.6.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants