Skip to main content
Glama

invoke_lambda_function_impl

Execute AWS Lambda functions with JSON payloads to access private resources, real-time data, or custom computations through the MCP2Lambda server.

Instructions

Tool that invokes an AWS Lambda function with a JSON payload. Before using this tool, list the functions available to you.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_nameYes
parametersYes

Implementation Reference

  • main.py:94-120 (handler)
    The core handler function for the 'invoke_lambda_function_impl' tool. Validates the function name, invokes the AWS Lambda function using boto3, handles errors, and formats the response payload.
    def invoke_lambda_function_impl(function_name: str, parameters: dict, ctx: Context) -> str:
        """Tool that invokes an AWS Lambda function with a JSON payload.
        Before using this tool, list the functions available to you."""
        
        if not validate_function_name(function_name):
            return f"Function {function_name} is not valid"
    
        ctx.info(f"Invoking {function_name} with parameters: {parameters}")
    
        response = lambda_client.invoke(
            FunctionName=function_name,
            InvocationType="RequestResponse",
            Payload=json.dumps(parameters),
        )
    
        ctx.info(f"Function {function_name} returned with status code: {response['StatusCode']}")
    
        if "FunctionError" in response:
            error_message = f"Function {function_name} returned with error: {response['FunctionError']}"
            ctx.error(error_message)
            return error_message
    
        payload = response["Payload"].read()
        
        # Format the response payload
        return format_lambda_response(function_name, payload)
  • main.py:126-126 (registration)
    Registration of the invoke_lambda_function_impl tool using the mcp.tool() decorator in the generic tools strategy.
    mcp.tool()(invoke_lambda_function_impl)
  • main.py:182-182 (registration)
    Fallback registration of the invoke_lambda_function_impl tool using the mcp.tool() decorator when dynamic registration fails.
    mcp.tool()(invoke_lambda_function_impl)
  • main.py:35-38 (helper)
    Helper function used by the handler to validate Lambda function names based on prefix or explicit list.
    def validate_function_name(function_name: str) -> bool:
        """Validate that the function name is valid and can be called."""
        return function_name.startswith(FUNCTION_PREFIX) or function_name in FUNCTION_LIST
  • main.py:56-65 (helper)
    Helper function used by the handler to format the Lambda response, preferring JSON pretty-printing.
    def format_lambda_response(function_name: str, payload: bytes) -> str:
        """Format the Lambda function response payload."""
        try:
            # Try to parse the payload as JSON
            payload_json = json.loads(payload)
            return f"Function {function_name} returned: {json.dumps(payload_json, indent=2)}"
        except (json.JSONDecodeError, UnicodeDecodeError):
            # Return raw payload if not JSON
            return f"Function {function_name} returned payload: {payload}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool invokes a Lambda function but doesn't mention critical behavioral traits such as authentication requirements, error handling, rate limits, or what happens upon invocation (e.g., synchronous vs. asynchronous execution). This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured with two sentences: the first states the purpose, and the second provides usage guidance. Every sentence earns its place by adding clear value without redundancy, making it front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of invoking a Lambda function, no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on authentication, execution behavior, error responses, and parameter specifics, which are essential for an agent to use this tool effectively in a real-world context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It mentions 'JSON payload' which relates to the 'parameters' parameter, adding some meaning beyond the schema. However, it doesn't explain the 'function_name' parameter or provide details on payload structure, format, or constraints, failing to fully address the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'invokes an AWS Lambda function with a JSON payload.' It specifies the verb ('invokes'), resource ('AWS Lambda function'), and payload type ('JSON payload'), which is specific and actionable. However, it doesn't explicitly differentiate from its sibling 'list_lambda_functions_impl' beyond the implied distinction between invocation and listing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'Before using this tool, list the functions available to you.' This indicates a prerequisite step involving the sibling tool 'list_lambda_functions_impl', offering clear context for usage. However, it lacks details on when not to use it or alternatives beyond this prerequisite.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danilop/MCP2Lambda'

If you have feedback or need assistance with the MCP directory API, please join our Discord server