Skip to content

Instantly share code, notes, and snippets.

View aal80's full-sized avatar

aal80 aal80

  • AWS
View GitHub Profile
resource "aws_lambda_function" "peppa_mcp_server" {
function_name = "peppa_mcp_server"
filename = data.archive_file.peppa_mcp_server.output_path
source_code_hash = data.archive_file.peppa_mcp_server.output_base64sha256
role = aws_iam_role.peppa_mcp_server.arn
handler = "index.handler"
runtime = "nodejs22.x"
memory_size = 512
timeout = 30
}
import serverlessExpress from '@codegenie/serverless-express';
import mcpServer from './mcpServer.js';
import transport from './transport-http.js';
const expressApp = await transport.bootstrap(mcpServer);
export const handler = serverlessExpress({ app: expressApp });
app.post(MCP_PATH, async (req, res) => {
try {
await transport.handleRequest(req, res, req.body);
} catch (err){
l.error(`Error handling MCP request ${err}`);
if (!res.headersSent) {
res.status(500).json({
jsonrpc: '2.0',
error: {
code: -32000,
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: undefined,
enableJsonResponse: true
});
await mcpServer.connect(transport);
const app = express();
app.use(express.json());
{
"mcpServers": {
"peppa": {
"command": "node",
"args": [
"/{fullpath}/peppa-pig-mcp-server-on-lambda/src/transport-stdio.js"
]
}
}
}
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import mcpServer from './mcpServer.js';
const transport = new StdioServerTransport();
await mcpServer.connect(transport);
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import resourceGetTimeslots from './resource-timeslots.js'
import toolOrderTickets from './tool-order-tickets.js'
const mcpServer = new McpServer({
name: "peppa-mcp-server-on-lambda",
version: "0.0.1"
}, {
capabilities: {
tools: {}
const toolName = 'order-tickets';
const toolDescription =
'Use this tool to order tickets to the Peppa Pig Park. \
The tool expects two parameters - timeslot and quantity. \
The timeslot should be a stringified date. \
The quantity should be a number. \
\
Example: \
order-tickets(timeslot: "April 19, 2025", quantity: 3) \
const resourceName = 'timeslots';
const resourceUri = 'peppa://timeslots';
const resourceMetadata = {
mimeType: 'text/plain',
description:
'Use this resource to get all open timeslots for ordering tickets \
to the Peppa Pig Theme Park.'
}