Skip to content

Conversation

@jiapingzeng
Copy link
Contributor

@jiapingzeng jiapingzeng commented Oct 29, 2025

Description

Create MCP client on each execute request + forward headers to MCP connector

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Accepted headers:

x-amzn-fas-accesskey, x-amzn-fas-secretkey, x-amzn-fas-sessiontoken, x-amzn-datasources

Sample request:

POST {{endpoint}}/_plugins/_ml/agents/{{agent_id}}/_execute
--header 'x-amzn-fas-accesskey: example' \
--header 'x-amzn-fas-secretkey: example' \
--header 'x-amzn-fas-sessiontoken: example' \
--header 'x-amzn-datasources: https://example.aos.us-east-1.on.aws' \
--header 'Content-Type: application/json'
{
    "parameters": {
        "question": "list indices"
    },
    "verbose": "true"
}

Response:

{
    "inference_results": [
        {
            "output": [
                {
                    "name": "memory_id",
                    "result": "F7vALZoBCqjo4z06S5j0"
                },
                {
                    "name": "parent_interaction_id",
                    "result": "GbvALZoBCqjo4z06TZiW"
                },
                {
                    "name": "response",
                    "dataAsMap": {
                        "response": "Here are the indices in your OpenSearch cluster:\n\n## User Indices\n1. **tmdb** - 8,516 documents, green health\n...",
                        "additional_info": {}
                    }
                }
            ]
        }
    ]
}

Copy link
Collaborator

@Zhangxunmt Zhangxunmt left a comment

Choose a reason for hiding this comment

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

spotless needs to apply

@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 29, 2025 19:48 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 29, 2025 19:48 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 29, 2025 19:48 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 29, 2025 19:48 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 01:54 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 01:54 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 01:54 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 01:54 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 02:15 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 02:15 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 02:15 — with GitHub Actions Waiting
@jiapingzeng jiapingzeng requested a deployment to ml-commons-cicd-env-require-approval October 30, 2025 02:15 — with GitHub Actions Waiting
Signed-off-by: Jiaping Zeng <[email protected]>
Signed-off-by: Jiaping Zeng <[email protected]>
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 8, 2025 22:22 — with GitHub Actions Failure
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 8, 2025 22:22 — with GitHub Actions Error
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 8, 2025 22:22 — with GitHub Actions Error
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 8, 2025 22:22 — with GitHub Actions Failure
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 9, 2025 02:04 — with GitHub Actions Failure
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 9, 2025 02:04 — with GitHub Actions Failure
@jiapingzeng jiapingzeng had a problem deploying to ml-commons-cicd-env-require-approval November 9, 2025 02:04 — with GitHub Actions Error
@jiapingzeng jiapingzeng temporarily deployed to ml-commons-cicd-env-require-approval November 9, 2025 02:04 — with GitHub Actions Inactive
public static final String DEFAULT_DATETIME_PREFIX = "Current date and time: ";
private static final ZoneId UTC_ZONE = ZoneId.of("UTC");

public static Map<String, String> extractRequestHeaders(Client client) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Are we planning to extract any other headers than MCP_REQUEST_HEADERS_THREAD_CONTEXT_KEY in this method if future? If not, suggest to rename the name to be more specific to this use case.

private static final String HEADER_FAS_SECRET_KEY = "x-amzn-fas-secretkey";
private static final String HEADER_FAS_SESSION_TOKEN = "x-amzn-fas-sessiontoken";
private static final String HEADER_DATASOURCES = "x-amzn-datasources";

Copy link
Contributor

Choose a reason for hiding this comment

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

can we change it to x-amzn-datasource-endpoint and add a new header x-amzn-datasource-type

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.

5 participants