@@ -5,10 +5,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
55import type { Tool } from '@modelcontextprotocol/sdk/types.js' ;
66import http from 'http' ;
77import { URL } from 'url' ;
8- import {
9- CallToolRequestSchema ,
10- ListToolsRequestSchema ,
11- } from '@modelcontextprotocol/sdk/types.js' ;
8+ import { CallToolRequestSchema , ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js' ;
129import { z } from 'zod' ;
1310import { StaticPixService } from './services/StaticPixService.js' ;
1411
@@ -18,7 +15,6 @@ const GenerateStaticPixSchema = z.object({
1815 amount : z . number ( ) . positive ( ) . max ( 999999.99 ) ,
1916 recipientName : z . string ( ) . min ( 1 ) . max ( 25 ) ,
2017 recipientCity : z . string ( ) . min ( 1 ) . max ( 15 ) ,
21- description : z . string ( ) . optional ( ) . default ( '' ) ,
2218} ) ;
2319
2420class PixMCPServer {
@@ -53,7 +49,8 @@ class PixMCPServer {
5349 tools : [
5450 {
5551 name : 'generateStaticPix' ,
56- description : 'Generate a static Pix QR code for any Pix key (works without API credentials)' ,
52+ description :
53+ 'Generate a static Pix QR code for any Pix key (works without API credentials)' ,
5754 inputSchema : {
5855 type : 'object' ,
5956 properties : {
@@ -81,11 +78,6 @@ class PixMCPServer {
8178 minLength : 1 ,
8279 maxLength : 15 ,
8380 } ,
84- description : {
85- type : 'string' ,
86- description : 'Optional payment description' ,
87- maxLength : 25 ,
88- } ,
8981 } ,
9082 required : [ 'pixKey' , 'amount' , 'recipientName' , 'recipientCity' ] ,
9183 } ,
@@ -112,7 +104,7 @@ class PixMCPServer {
112104 case 'generateStaticPix' : {
113105 const validatedArgs = GenerateStaticPixSchema . parse ( args ) ;
114106 const result = await this . staticPixService . createStaticPix ( validatedArgs ) ;
115-
107+
116108 return {
117109 content : [
118110 {
@@ -122,7 +114,6 @@ class PixMCPServer {
122114**Payment Details:**
123115- Amount: R$ ${ result . paymentDetails . amountFormatted }
124116- Recipient: ${ result . paymentDetails . recipient }
125- - Description: ${ result . paymentDetails . description || 'N/A' }
126117- PIX Key: ${ result . paymentDetails . pixKey }
127118- City: ${ result . paymentDetails . city }
128119
@@ -132,9 +123,9 @@ class PixMCPServer {
132123**QR Code:**
133124${ result . qrCodeDataUrl ? `` : 'QR Code generation failed' }
134125
135- ⚠️ **Note**: This is a static Pix code. Payment confirmation must be checked manually by the recipient.`
136- }
137- ]
126+ ⚠️ **Note**: This is a static Pix code. Payment confirmation must be checked manually by the recipient.` ,
127+ } ,
128+ ] ,
138129 } ;
139130 }
140131
@@ -144,17 +135,17 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
144135 timestamp : new Date ( ) . toISOString ( ) ,
145136 version : '2.0.0' ,
146137 mode : 'static-pix' ,
147- status : 'operational'
138+ status : 'operational' ,
148139 } ;
149-
140+
150141 return {
151142 content : [
152143 {
153144 type : 'text' ,
154- text : `✅ Server is healthy\nVersion: ${ status . version } \nMode: ${ status . mode } \nStatus: ${ status . status } `
155- }
145+ text : `✅ Server is healthy\nVersion: ${ status . version } \nMode: ${ status . mode } \nStatus: ${ status . status } ` ,
146+ } ,
156147 ] ,
157- status
148+ status,
158149 } ;
159150 }
160151
@@ -182,23 +173,25 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
182173 res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
183174 res . setHeader ( 'Access-Control-Allow-Methods' , 'GET, POST, OPTIONS' ) ;
184175 res . setHeader ( 'Access-Control-Allow-Headers' , 'Content-Type, Authorization' ) ;
185-
176+
186177 if ( req . method === 'OPTIONS' ) {
187178 res . writeHead ( 200 ) ;
188179 res . end ( ) ;
189180 return ;
190181 }
191182
192183 const url = new URL ( req . url ! , `http://${ req . headers . host } ` ) ;
193-
184+
194185 if ( url . pathname === '/health' ) {
195186 res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
196- res . end ( JSON . stringify ( {
197- status : 'healthy' ,
198- service : 'pix-mcp-server' ,
199- version : '1.0.0' ,
200- timestamp : new Date ( ) . toISOString ( )
201- } ) ) ;
187+ res . end (
188+ JSON . stringify ( {
189+ status : 'healthy' ,
190+ service : 'pix-mcp-server' ,
191+ version : '1.0.0' ,
192+ timestamp : new Date ( ) . toISOString ( ) ,
193+ } )
194+ ) ;
202195 return ;
203196 }
204197
@@ -223,18 +216,14 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
223216 minLength : 1 ,
224217 maxLength : 100 ,
225218 } ,
226- description : {
227- type : 'string' ,
228- description : 'Optional payment description' ,
229- maxLength : 200 ,
230- } ,
231219 } ,
232220 required : [ 'amount' , 'recipientName' ] ,
233221 } ,
234222 } ,
235223 {
236224 name : 'generateStaticPix' ,
237- description : 'Generate a static Pix QR code for any Pix key (works without API credentials)' ,
225+ description :
226+ 'Generate a static Pix QR code for any Pix key (works without API credentials)' ,
238227 inputSchema : {
239228 type : 'object' ,
240229 properties : {
@@ -262,11 +251,6 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
262251 minLength : 1 ,
263252 maxLength : 15 ,
264253 } ,
265- description : {
266- type : 'string' ,
267- description : 'Optional payment description' ,
268- maxLength : 25 ,
269- } ,
270254 } ,
271255 required : [ 'pixKey' , 'amount' , 'recipientName' , 'recipientCity' ] ,
272256 } ,
@@ -289,37 +273,38 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
289273
290274 if ( url . pathname === '/tools/call' && req . method === 'POST' ) {
291275 let body = '' ;
292- req . on ( 'data' , chunk => body += chunk ) ;
276+ req . on ( 'data' , ( chunk ) => ( body += chunk ) ) ;
293277 req . on ( 'end' , async ( ) => {
294278 try {
295279 const { name, arguments : args } = JSON . parse ( body ) ;
296-
280+
297281 // Handle tool calls directly
298282 if ( name === 'generateStaticPix' ) {
299283 const validatedArgs = GenerateStaticPixSchema . parse ( args ) ;
300284 const result = await this . staticPixService . createStaticPix ( validatedArgs ) ;
301-
285+
302286 const response = {
303- content : [ {
304- type : 'text' ,
305- text : `✅ Static Pix QR code generated successfully!
287+ content : [
288+ {
289+ type : 'text' ,
290+ text : `✅ Static Pix QR code generated successfully!
306291
307292**Payment Details:**
308293- Amount: ${ result . paymentDetails . amountFormatted }
309294- Recipient: ${ result . paymentDetails . recipient }
310295- City: ${ result . paymentDetails . city }
311- - Description: ${ result . paymentDetails . description || 'N/A' }
312296
313297**Pix Code (copy and paste):**
314298\`${ result . pixCode } \`
315299
316300**QR Code:**
317301${ result . qrCodeDataUrl ? `` : 'QR Code generation failed' }
318302
319- ⚠️ **Note**: This is a static Pix code. Payment confirmation must be checked manually by the recipient.`
320- } ]
303+ ⚠️ **Note**: This is a static Pix code. Payment confirmation must be checked manually by the recipient.` ,
304+ } ,
305+ ] ,
321306 } ;
322-
307+
323308 res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
324309 res . end ( JSON . stringify ( response ) ) ;
325310 } else if ( name === 'healthCheck' ) {
@@ -328,23 +313,25 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
328313 timestamp : new Date ( ) . toISOString ( ) ,
329314 version : '2.0.0' ,
330315 mode : 'static-pix' ,
331- status : 'operational'
316+ status : 'operational' ,
332317 } ;
333-
318+
334319 const response = {
335- content : [ {
336- type : 'text' ,
337- text : `🟢 **Pix MCP Server Health Check**
320+ content : [
321+ {
322+ type : 'text' ,
323+ text : `🟢 **Pix MCP Server Health Check**
338324
339325**Status:** ${ status . server }
340326**Version:** ${ status . version }
341327**Mode:** ${ status . mode }
342328**Timestamp:** ${ status . timestamp }
343329
344- ✅ All systems operational`
345- } ]
330+ ✅ All systems operational` ,
331+ } ,
332+ ] ,
346333 } ;
347-
334+
348335 res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
349336 res . end ( JSON . stringify ( response ) ) ;
350337 } else {
@@ -353,10 +340,12 @@ ${result.qrCodeDataUrl ? `` : 'QR Code genera
353340 } catch ( error ) {
354341 const errorMessage = error instanceof Error ? error . message : 'Unknown error occurred' ;
355342 const response = {
356- content : [ {
357- type : 'text' ,
358- text : `❌ Error: ${ errorMessage } ` ,
359- } ] ,
343+ content : [
344+ {
345+ type : 'text' ,
346+ text : `❌ Error: ${ errorMessage } ` ,
347+ } ,
348+ ] ,
360349 isError : true ,
361350 } ;
362351 res . writeHead ( 400 , { 'Content-Type' : 'application/json' } ) ;
0 commit comments