Skip to content

feat(async): mcp async call tool #406

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
merged 1 commit into from
Jul 10, 2025
Merged

Conversation

jer96
Copy link
Member

@jer96 jer96 commented Jul 10, 2025

Description

This is a followup to #391 to provide an call_tool_async function for the MCP client.

Related Issues

Documentation PR

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare
  • I ran hatch run test-integ (all test case pass)

Sample script:

import logging

from mcp import StdioServerParameters, stdio_client

from strands import Agent
from strands.models.openai import OpenAIModel
from strands.tools.mcp import MCPClient

logging.basicConfig(level=logging.DEBUG)

API_KEY="<insert api key>"

stdio_mcp_client = MCPClient(
    lambda: stdio_client(StdioServerParameters(command="uvx", args=["awslabs.aws-documentation-mcp-server@latest"]))
)

with stdio_mcp_client:
    tools = stdio_mcp_client.list_tools_sync()

    model = OpenAIModel(
        {
            "api_key": API_KEY,
        },
        model_id="gpt-4o",
    )
    agent = Agent(model=model, tools=tools, callback_handler=None)
    result = agent("what tools do you have")
    result = agent("get me details about lambda, dynamodb, sqs and aurora")
    print(result.message)

Output

I also confirmed that there are 4 tool invocations to the aws-documentation mcp server - which hits the code implemented in this PR.

{
    "role": "assistant",
    "content": [
        {
            "text": "Here are some details and links to the AWS documentation for Lambda, DynamoDB, SQS, and Aurora:\n\n### AWS Lambda\n1. [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/): Comprehensive documentation including User Guides, API References, Developer Guides, and other resources.\n2. [AWS Lambda API Reference](https://docs.aws.amazon.com/lambda/latest/dg/API_Reference.html): Describes all Lambda API operations with detailed information, sample requests, responses, and errors.\n3. [AWS Lambda CLI](https://docs.aws.amazon.com/cli/latest/reference/lambda/): Provides AWS CLI commands, concepts, and notations for AWS Lambda.\n\n### Amazon DynamoDB\n1. [Amazon DynamoDB Documentation](https://docs.aws.amazon.com/dynamodb/): In-depth documentation including User Guides, API References, Developer Guides, and more.\n2. [Amazon DynamoDB User Guide](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/): Detailed information and instructions for getting started and developing with DynamoDB.\n3. [Amazon DynamoDB API Reference](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/): Detailed descriptions of all DynamoDB API operations with sample requests, responses, and errors.\n\n### Amazon SQS (Simple Queue Service)\n1. [Amazon Simple Queue Service Documentation](https://docs.aws.amazon.com/sqs/): Comprehensive resources including User Guides, API References, Developer Guides, and more.\n2. [Amazon Simple Queue Service User Guide](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/): Instructions and details for using and developing with Amazon SQS.\n3. [Amazon Simple Queue Service API Reference](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/): Complete description of SQS API operations, including sample requests and responses.\n\n### Amazon Aurora\n1. [Amazon Aurora Documentation](https://docs.aws.amazon.com/rds/): Detailed documentation for Aurora, including User Guides and API References.\n2. [Amazon Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/): Instructions for getting started and developing with Amazon Aurora.\n3. [Amazon Aurora API Reference](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/Welcome.html): Detailed descriptions of Aurora API operations with examples.\n\nThese documents should provide you with extensive information on each AWS service! If you need more specific details or help, feel free to ask."
        }
    ]
}

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jer96 jer96 temporarily deployed to auto-approve July 10, 2025 14:46 — with GitHub Actions Inactive
@jer96 jer96 marked this pull request as ready for review July 10, 2025 14:57
@jer96 jer96 enabled auto-merge (squash) July 10, 2025 17:18
@jer96 jer96 merged commit ea81326 into strands-agents:main Jul 10, 2025
42 of 52 checks passed
@jer96 jer96 mentioned this pull request Jul 11, 2025
7 tasks
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