Skip to content

Fix dynamic tooling#28

Merged
kyoncal merged 12 commits into
aws:mainfrom
kyoncal:fix/dynamic-tools
Oct 7, 2025
Merged

Fix dynamic tooling#28
kyoncal merged 12 commits into
aws:mainfrom
kyoncal:fix/dynamic-tools

Conversation

@kyoncal

@kyoncal kyoncal commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Summary

Changes

  • Removed mcp_proxy_manager.py and redundant MCP server.
  • Moved filtering to middleware
  • Moved middleware adding to server.py
  • Fixed and added relevant unit tests
  • Fixed logging by outputting to the correct channel

User experience

The user's tools should pass through the proxy transparently instead of being incorrectly cached.
The user should be able to see proper logs

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • These changes were tested manually, alongside the suite of automated tests. The manual tests consisted of creating a simple client to repeated query a mock-server through the proxy to verify that the proxy works and now has the desired behavior of querying the back end instead of caching results.
  • Changes are documented

Is this a breaking change? (Y/N)

  • Yes
  • No

Acknowledgment

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

@kyoncal kyoncal self-assigned this Oct 3, 2025
@kyoncal kyoncal requested a review from a team as a code owner October 3, 2025 14:28

@arangatang arangatang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the changes, one major thing, we need to ensure that proper logging is maintained, did you verify that errors/info/debug logs are propagated properly to i.e. qcli, cline, cursor, terminal etc?
A user must be able to identify problems and such and last I remember from the terminal logs were not showing up. At the very least i'm thinking we should have smth like:

  1. Connection to endpoint successfull
  2. Exceptions bubbling up when stuff breaks like network
  3. Optional - ListTools called (and how many was filtered out)

Comment thread aws_mcp_proxy/server.py Outdated
Comment thread aws_mcp_proxy/middleware/tool_filter.py Outdated
Comment thread aws_mcp_proxy/middleware/tool_filter.py Outdated
Comment thread aws_mcp_proxy/server.py Outdated
@kyoncal kyoncal force-pushed the fix/dynamic-tools branch from 6fd659b to ea8c905 Compare October 6, 2025 08:47

@wzxxing wzxxing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also add some description of how this change was tested.

Comment thread aws_mcp_proxy/middleware/tool_filter.py
Comment thread aws_mcp_proxy/middleware/tool_filter.py Outdated
Comment thread tests/unit/test_tool_filter.py

@wzxxing wzxxing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can run pre-commit install so that the linters are checked before updating the PR.

@kyoncal kyoncal force-pushed the fix/dynamic-tools branch from bbe670e to 8fa5769 Compare October 6, 2025 14:18
@kyoncal

kyoncal commented Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the changes, one major thing, we need to ensure that proper logging is maintained, did you verify that errors/info/debug logs are propagated properly to i.e. qcli, cline, cursor, terminal etc? A user must be able to identify problems and such and last I remember from the terminal logs were not showing up. At the very least i'm thinking we should have smth like:

1. Connection to endpoint successfull

2. Exceptions bubbling up when stuff breaks like network

3. Optional - ListTools called (and how many was filtered out)

Thanks for the comment. The logs have stayed essentially identical, outside of the change in behavior with regard to removing the mcp_proxy_manager. Also the logging has been fixed, so the user can now see logs in their terminal. I believe this addresses your points. Let me know!

@kyoncal kyoncal requested review from a team, arangatang and wzxxing October 6, 2025 14:42
@kyoncal kyoncal force-pushed the fix/dynamic-tools branch from 114ef38 to 39b5e61 Compare October 6, 2025 14:43
Comment thread aws_mcp_proxy/logging_config.py
Comment thread aws_mcp_proxy/server.py
if args.retries:
add_retry_middleware(proxy, args.retries)

await proxy.run_async()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is this run_async lifted to this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I directly replaced the first call to mcp_proxy_manager with it, although it's original placement outside of this function does make more sense and we can directly run the function.

Comment thread aws_mcp_proxy/server.py
logger = logging.getLogger(__name__)


async def setup_mcp_mode(local_mcp: FastMCP, args) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

local_mcp is not used any more, can we directly run this function? Since the fastmcp instance created in main is not used anymore?

@kyoncal kyoncal Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We'd have to use asyncio.run somewhere, since we can't really await the main method, so we'd just be hoisting it elsewhere. I think it makes sense where it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I meant the local_mcp is not used any more, we can remove this argument, also remove the FastMCP instance created in main.

@kyoncal kyoncal requested a review from wzxxing October 6, 2025 16:26
Comment thread aws_mcp_proxy/server.py
await proxy.run_async()


def add_tool_filtering_middleware(mcp: FastMCP, read_only: bool = False) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rant for another PR/issue (we should review the code for this in general).

  1. We should not have default values where they are not needed, we should fail rather than accidentally set defaults if omitted. Makes stuff less prone of unexpected behaviour as the code grows.
  2. Ideally we should probably be using kwargs instead of args everywhere, more verbose but much more scalable.
  3. We should use proper typing

Probs I should create an issue for this tbh, when thinking about it.

@kyoncal kyoncal merged commit e64a95f into aws:main Oct 7, 2025
3 checks passed
@kyoncal kyoncal deleted the fix/dynamic-tools branch October 7, 2025 09:41
Comment thread aws_mcp_proxy/server.py
logger.info('Starting AWS MCP Proxy Server')

# Create FastMCP instance
mcp = FastMCP[Any](

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not used anymore.

We can rename setup_mcp_mode to run_mcp_proxy

Comment thread aws_mcp_proxy/server.py
raise

# Run the server
asyncio.run(setup_and_run())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then simply do asyncio.run(run_mcp_proxy(args)) here

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.

4 participants