Skip to content

Feature request: MCP server event handler #6562

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

Open
2 tasks done
ran-isenberg opened this issue Apr 25, 2025 · 6 comments
Open
2 tasks done

Feature request: MCP server event handler #6562

ran-isenberg opened this issue Apr 25, 2025 · 6 comments
Labels

Comments

@ran-isenberg
Copy link
Contributor

ran-isenberg commented Apr 25, 2025

Use case

i'd like to be able to write serverless MCP servers with ease and integrate all my powertools capabilities:
swagger, event validation, event resolver, logger, tracing, metrics etc.

Solution/User Experience

I'd like to have UX like in https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#response-auto-serialization but combined with the official python SDK for MCP server with all the right config to make it work on a lambda.

# server.py
from aws_lambda_powertools.event_handler import MCPResolver

mcp = MCPResolver('myMcp)

# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"


# You can continue to use other utilities just as before
@logger.inject_lambda_context()
@tracer.capture_lambda_handler
def lambda_handler(event: dict, context: LambdaContext) -> dict:
    return mcp.resolve(event, context)

Alternative solutions

use unknown open sources like MCPEngine and build my own wrappers for logging/tracer.. i want the powertools edition :)

Acknowledgment

@ran-isenberg ran-isenberg added feature-request feature request triage Pending triage from maintainers labels Apr 25, 2025
@dreamorosi dreamorosi added event_handlers and removed triage Pending triage from maintainers labels Apr 25, 2025
@dreamorosi dreamorosi moved this from Triage to Ideas in Powertools for AWS Lambda (Python) Apr 25, 2025
@dreamorosi
Copy link
Contributor

Hi @ran-isenberg, thank you for opening this feature request.

Everyone is talking about MCPs these days so I am not surprised to see a feature request in this space finally arriving to our project.

I am wondering if you could share - either here or privately via email - whether there are specific use cases that you're considering at CyberArk that this MCP resolver would help with.

Also on a more technical level, I'm wondering if you had any opinions/suggestions on how we should handle authentication with this type of resolver, the spec for MCP is still very blurry around this type of concerns.

Finally, from a governance standpoint, before implementing this we'll have to discuss how to release this. The Powertools for AWS brand has certain commitments around stability and versioning (highlighted in our wiki) that I'm not sure would fit with a spec still very much in flux like MCP.

@ran-isenberg
Copy link
Contributor Author

We can talk over discord if you wish, but yeah I have some ideas and needs :)
As more auth/authz. When you place it behind API GW, you can use WAF, IAM auth/cognito/any JWT token authorization. See https://github.com/mikegc-aws/Lambda-MCP-Server - he added a custom authorizer.
Also MCPEngine added support for idp token validatioin.
I've been trying to build a proper cookbook for this with powertools but lack of official SDK support, and seeing lots of sh*tty implementations (that I cant recommend), and the fact that this is sooo new for serverless (protocol changed this week to support non streaming HTTP), leaves me wanting the Powertools treatment :)

@walmsles
Copy link
Contributor

Hey @ran-isenberg and @dreamorosi have you seen this from Mike Chambers: https://github.com/mikegc-aws/Lambda-MCP-Server

This might be of interest - I think this could be a good thing to import into Powertools, to be honest.

@ran-isenberg
Copy link
Contributor Author

ran-isenberg commented Apr 30, 2025

Hey @ran-isenberg and @dreamorosi have you seen this from Mike Chambers: https://github.com/mikegc-aws/Lambda-MCP-Server

This might be of interest - I think this could be a good thing to import into Powertools, to be honest.

I did, i dont want to offend anyone but it's a nice poc level code. I got it working with powertools.
However, i think i'd rather use official mcp python SDK to support http non streaming mode.

Waiting for this: https://github.com/modelcontextprotocol/python-sdk

@dreamorosi
Copy link
Contributor

Hey @walmsles & @ran-isenberg - would you two be available for a quick call in the next week or two?

I'd love to pick your brain on this topic. If we can manage to do it in one call it'd be amazing, but if time zones are a challenge I'm happy to also do one for each.

@ran-isenberg
Copy link
Contributor Author

two weeks from now should be fine, talk to me on discord next week, it's a holiday now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

3 participants