#4675·mcp

iam-mcp-server 1.1.1: list_users/get_user still fail with "ctx Field required"

Author: newbiehwangCreated Sep 25, 2026Updated Sep 25, 2026
Labelsbugneeds-triage

Describe the bug

In iam-mcp-server 1.1.1, list_users, get_user and create_user annotate ctx as CallToolResult instead of the MCP Context type. Because of this, the SDK exposes ctx as a required input argument in the tool schema, and every call fails with a validation error. This was reported in #1463 and a fix was proposed in #1464, but both were closed as stale without being merged, and the bug is still present.

Expected Behavior

ctx is injected by the server and does not appear in the tool input schema. list_users works without arguments, and get_user works with only user_name.

Current Behavior

The input schema of list_users / get_user lists ctx as required, and calling them returns:

1 validation error for list_usersArguments
ctx
  Field required

Reproduction Steps

pip install awslabs.iam-mcp-server==1.1.1 fastmcp

import asyncio
from fastmcp import Client
from awslabs.iam_mcp_server.server import mcp

async def main():
    async with Client(mcp) as client:
        tools = {t.name: t for t in await client.list_tools()}
        print(tools["list_users"].input_schema.get("required"))  # contains 'ctx'
        result = await client.call_tool("list_users", {}, raise_on_error=False)
        print(result.content[0].text)  # "ctx Field required"

asyncio.run(main())

Possible Solution

Import the MCP context under an alias to avoid the name clash with the server's own Context class, and use it for ctx in list_users, get_user and create_user:

from mcp.server.mcpserver import Context as McpContext, MCPServer

(#1464 did the same with mcp.server.fastmcp, which the server no longer uses after #4452.)

Additional Information/Context

Still present on main. The last change to server.py is 13b1309 (#4452, migration to MCP SDK v2, 2026-08-25), and list_users, get_user and create_user still annotate ctx as CallToolResult. The fix proposed in #1464 no longer applies as-is, because it imports Context from mcp.server.fastmcp, while the server now uses mcp.server.mcpserver.

Likely root cause. server.py already imports the server's own configuration class as Context (from awslabs.iam_mcp_server.context import Context), so the MCP Context could not be imported under the same name. #1464 solved this by renaming the local import to ServerContext.

Verified fix. I changed only these lines locally and it resolves the problem:

from mcp.server.mcpserver import Context as McpContext, MCPServer
...
ctx: McpContext,   # in list_users, get_user, create_user
1.1.1 with the change
list_users required args ['ctx'] none
get_user required args ['ctx', 'user_name'] ['user_name']
create_user required args ['ctx', 'user_name'] ['user_name']
list_users call ctx Field required succeeds

Environment: Python 3.12.11, mcp 2.2.0, fastmcp 4.0.9 (AWS calls mocked with moto).

Impact. list_users and get_user are the most basic read-only tools of this server, and they cannot be called from any MCP client, including in read-only mode. The other 26 tools are not affected.

Current workaround (downstream). We hide ctx from the tool schema and inject a dummy value when calling these two tools. It works because the functions never use ctx, but a fix upstream would let us remove it.

I'm happy to open a PR with this change if that helps.

OS

macOS

Server

iam-mcp-server

Server Version

1.1.1

Region experiencing the issue

ap-southeast-2

Other information

No response

Service quota

  • I have reviewed the service quotas for this construct