Describe the bug
The IAM MCP server tools cannot be called via MCP protocol because they incorrectly expose the internal ctx parameter in their tool schemas. This causes all tool calls to fail with a validation error requiring the ctx parameter.
Expected Behavior
Tool calls should succeed when called with only the documented parameters (e.g., path_prefix, max_items for list_users). The ctx parameter should be automatically injected by the FastMCP framework and excluded from the tool schema.
Current Behavior
Tool calls fail with validation error:
Error executing tool list_users: 1 validation error for list_usersArguments
ctx
Field required [type=missing, input_value={'max_items': 5}, input_type=dict]
The tool schema incorrectly includes ctx as a required parameter with type CallToolResult.
Reproduction Steps
- Connect to IAM MCP server using official MCP Python SDK:
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="uvx",
args=["awslabs.iam-mcp-server@latest", "--readonly"],
env={"AWS_PROFILE": "your-profile", "AWS_REGION": "us-east-1"}
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# This call fails with ctx validation error
result = await session.call_tool("list_users", arguments={})
- Observe validation error in result.content
Possible Solution
Change the ctx parameter type from CallToolResult to Context from mcp.server.fastmcp:
Current (incorrect):
from mcp.types import CallToolResult
@mcp.tool()
async def list_users(
ctx: CallToolResult, # Wrong type - gets exposed in schema
path_prefix: Optional[str] = None,
max_items: int = 100,
) -> UsersListResponse:
Fixed:
from mcp.server.fastmcp import Context
@mcp.tool()
async def list_users(
ctx: Context, # Correct type - automatically excluded from schema
path_prefix: Optional[str] = None,
max_items: int = 100,
) -> UsersListResponse:
This affects 3 tools: list_users, get_user, and create_user.
Additional Information/Context
- The FastMCP framework automatically excludes parameters typed as
Context from tool schemas
- Using
CallToolResult (from mcp.types) instead of Context (from mcp.server.fastmcp) causes the parameter to be exposed
- This appears to be a typo/oversight from when the tools were created
- No other tools in the server use
ctx parameter, suggesting incomplete migration
Environment
OS: Linux (Ubuntu 22.04)
Server: iam-mcp-server
Server Version: 1.0.6
Region: us-east-1
Service Quota
Describe the bug
The IAM MCP server tools cannot be called via MCP protocol because they incorrectly expose the internal
ctxparameter in their tool schemas. This causes all tool calls to fail with a validation error requiring thectxparameter.Expected Behavior
Tool calls should succeed when called with only the documented parameters (e.g.,
path_prefix,max_itemsforlist_users). Thectxparameter should be automatically injected by the FastMCP framework and excluded from the tool schema.Current Behavior
Tool calls fail with validation error:
The tool schema incorrectly includes
ctxas a required parameter with typeCallToolResult.Reproduction Steps
Possible Solution
Change the
ctxparameter type fromCallToolResulttoContextfrommcp.server.fastmcp:Current (incorrect):
Fixed:
This affects 3 tools:
list_users,get_user, andcreate_user.Additional Information/Context
Contextfrom tool schemasCallToolResult(frommcp.types) instead ofContext(frommcp.server.fastmcp) causes the parameter to be exposedctxparameter, suggesting incomplete migrationEnvironment
OS: Linux (Ubuntu 22.04)
Server: iam-mcp-server
Server Version: 1.0.6
Region: us-east-1
Service Quota