MCPcopy Create free account
hub / github.com/serverless/examples / createMcpServer

Function createMcpServer

aws-bedrock-agentcore/javascript/mcp-server/index.js:22–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20// ---------------------------------------------------------------------------
21
22const createMcpServer = () => {
23 const server = new McpServer({
24 name: 'mcp-server',
25 version: '1.0.0',
26 })
27
28 // Tool: add two numbers
29 server.registerTool(
30 'add',
31 {
32 title: 'Addition',
33 description: 'Add two numbers together',
34 inputSchema: {
35 a: z.number().describe('First number'),
36 b: z.number().describe('Second number'),
37 },
38 },
39 async ({ a, b }) => ({
40 content: [{ type: 'text', text: String(a + b) }],
41 }),
42 )
43
44 // Tool: multiply two numbers
45 server.registerTool(
46 'multiply',
47 {
48 title: 'Multiplication',
49 description: 'Multiply two numbers together',
50 inputSchema: {
51 a: z.number().describe('First number'),
52 b: z.number().describe('Second number'),
53 },
54 },
55 async ({ a, b }) => ({
56 content: [{ type: 'text', text: String(a * b) }],
57 }),
58 )
59
60 // Tool: get current time
61 server.registerTool(
62 'get_current_time',
63 {
64 title: 'Current Time',
65 description:
66 'Get the current date and time. Optionally specify a timezone.',
67 inputSchema: {
68 timezone: z
69 .string()
70 .optional()
71 .describe(
72 'Timezone (e.g. "America/New_York", "Europe/London", "UTC")',
73 ),
74 },
75 },
76 async ({ timezone }) => {
77 const now = new Date()
78 const options = {
79 timeZone: timezone || 'UTC',

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected