Skip to content

Commit be56338

Browse files
committed
Fix pyright errors
1 parent 8ad2f2e commit be56338

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

examples/mcp-client/langchain/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from contextlib import asynccontextmanager
4646
from langchain.agents import create_agent as create_langchain_agent
4747
from langchain_aws import ChatBedrock
48+
from langchain_core.messages import HumanMessage
4849
from langchain_mcp_adapters.tools import load_mcp_tools
4950
from mcp.client.session import ClientSession
5051
from mcp_proxy_for_aws.client import aws_iam_mcp_client
@@ -91,13 +92,13 @@ async def create_agent():
9192

9293
# Create the agent with access to the tools
9394
agent = create_langchain_agent(
94-
model=ChatBedrock(model_id=BEDROCK_MODEL_ID), tools=mcp_tools
95+
model=ChatBedrock(model=BEDROCK_MODEL_ID), tools=mcp_tools
9596
)
9697

9798
# Yield a callable interface to the agent
9899
async def agent_callable(user_input: str) -> str:
99100
"""Send a message to the agent and return its response."""
100-
result = await agent.ainvoke({'messages': [('user', user_input)]})
101+
result = await agent.ainvoke({'messages': [HumanMessage(content=user_input)]})
101102
return result['messages'][-1].content
102103

103104
yield agent_callable

mcp_proxy_for_aws/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ def aws_iam_mcp_client(
7777
session = boto3.Session(**kwargs)
7878

7979
profile = session.profile_name
80-
region: str = session.region_name
80+
region = session.region_name
81+
82+
if not region:
83+
raise ValueError(
84+
'AWS region must be specified via aws_region parameter, AWS_PROFILE environment variable, or AWS config.'
85+
)
8186

8287
logger.debug('AWS profile: %s', profile)
8388
logger.debug('AWS region: %s', region)

0 commit comments

Comments
 (0)