This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const transport = new StreamableHTTPServerTransport({ | |
sessionIdGenerator: undefined, | |
enableJsonResponse: true | |
}); | |
await mcpServer.connect(transport); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = express(); | |
app.use(express.json()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"mcpServers": { | |
"peppa": { | |
"command": "node", | |
"args": [ | |
"/{fullpath}/peppa-pig-mcp-server-on-lambda/src/transport-stdio.js" | |
] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | |
import mcpServer from './mcpServer.js'; | |
const transport = new StdioServerTransport(); | |
await mcpServer.connect(transport); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.' | |
} |
NewerOlder