@@ -14,9 +14,15 @@ async function main() {
1414 console . log ( "Starting MCP Sample Application...\n" ) ;
1515
1616 // Import MCP SDK modules FIRST (before traceloop.initialize)
17- const mcpClientModule = await import ( "@modelcontextprotocol/sdk/client/index.js" ) ;
18- const mcpServerModule = await import ( "@modelcontextprotocol/sdk/server/mcp.js" ) ;
19- const mcpInMemoryModule = await import ( "@modelcontextprotocol/sdk/inMemory.js" ) ;
17+ const mcpClientModule = await import (
18+ "@modelcontextprotocol/sdk/client/index.js"
19+ ) ;
20+ const mcpServerModule = await import (
21+ "@modelcontextprotocol/sdk/server/mcp.js"
22+ ) ;
23+ const mcpInMemoryModule = await import (
24+ "@modelcontextprotocol/sdk/inMemory.js"
25+ ) ;
2026
2127 const { Client } = mcpClientModule ;
2228 const { McpServer } = mcpServerModule ;
@@ -35,7 +41,8 @@ async function main() {
3541 console . log ( "✓ Traceloop initialized with MCP instrumentation\n" ) ;
3642
3743 // Create linked transport pair for in-memory client-server communication
38- const [ clientTransport , serverTransport ] = InMemoryTransport . createLinkedPair ( ) ;
44+ const [ clientTransport , serverTransport ] =
45+ InMemoryTransport . createLinkedPair ( ) ;
3946
4047 // Create and configure MCP server with tools and resources
4148 const server = new McpServer (
@@ -115,15 +122,23 @@ async function main() {
115122
116123 // 2. Call the add tool
117124 console . log ( "2. Calling add tool with a=5, b=3..." ) ;
118- const addResult = await client . callTool ( { name : "add" , arguments : { a : 5 , b : 3 } } ) ;
125+ const addResult = await client . callTool ( {
126+ name : "add" ,
127+ arguments : { a : 5 , b : 3 } ,
128+ } ) ;
119129 // eslint-disable-next-line @typescript-eslint/no-explicit-any
120130 console . log ( ` Result: ${ ( ( addResult as any ) . content [ 0 ] as any ) . text } \n` ) ;
121131
122132 // 3. Call the multiply tool
123133 console . log ( "3. Calling multiply tool with x=4, y=7..." ) ;
124- const multiplyResult = await client . callTool ( { name : "multiply" , arguments : { x : 4 , y : 7 } } ) ;
134+ const multiplyResult = await client . callTool ( {
135+ name : "multiply" ,
136+ arguments : { x : 4 , y : 7 } ,
137+ } ) ;
125138 // eslint-disable-next-line @typescript-eslint/no-explicit-any
126- console . log ( ` Result: ${ ( ( multiplyResult as any ) . content [ 0 ] as any ) . text } \n` ) ;
139+ console . log (
140+ ` Result: ${ ( ( multiplyResult as any ) . content [ 0 ] as any ) . text } \n` ,
141+ ) ;
127142
128143 // 4. List available resources
129144 console . log ( "4. Listing available resources..." ) ;
@@ -149,13 +164,15 @@ async function main() {
149164 console . log ( " ├─ initialize.mcp (initialization)" ) ;
150165 console . log ( " ├─ tools/list.mcp (output: {tools: [...]})" ) ;
151166 console . log ( " ├─ add.tool (input: {a: 5, b: 3}, output: {result: '8'})" ) ;
152- console . log ( " ├─ multiply.tool (input: {x: 4, y: 7}, output: {result: '28'})" ) ;
167+ console . log (
168+ " ├─ multiply.tool (input: {x: 4, y: 7}, output: {result: '28'})" ,
169+ ) ;
153170 console . log ( " ├─ resources/list.mcp (output: {resources: [...]})" ) ;
154- console . log ( " └─ resources/read.mcp (input: {uri: 'calc://info'}, output: {contents: [...]})" ) ;
155- console . log ( "\n✓ All spans created with SUCCESS status (no errors!)" ) ;
156171 console . log (
157- "\nNote: Traces are being exported to your configured endpoint. " ,
172+ " └─ resources/read.mcp (input: {uri: 'calc://info'}, output: {contents: [...]}) " ,
158173 ) ;
174+ console . log ( "\n✓ All spans created with SUCCESS status (no errors!)" ) ;
175+ console . log ( "\nNote: Traces are being exported to your configured endpoint." ) ;
159176 console . log (
160177 "Set TRACELOOP_API_KEY environment variable to send traces to Traceloop." ,
161178 ) ;
0 commit comments