(server)
| 53 | * @param {McpServer} server - The MCP server instance to register tools on |
| 54 | */ |
| 55 | export function registerTools(server) { |
| 56 | // Helper functions for dynamic date generation |
| 57 | const getNow = () => new Date() |
| 58 | const getThreeHoursAgo = () => new Date(Date.now() - 3 * 60 * 60 * 1000) |
| 59 | const getTwentyFourHoursAgo = () => new Date(Date.now() - 24 * 60 * 60 * 1000) |
| 60 | const getFifteenMinutesAgo = () => new Date(Date.now() - 15 * 60 * 1000) |
| 61 | |
| 62 | // Get today's date in ISO format for examples |
| 63 | const getTodayDate = () => { |
| 64 | const today = new Date() |
| 65 | // Return the full ISO string which includes the correct timezone (Z indicates UTC) |
| 66 | return today.toISOString() |
| 67 | } |
| 68 | |
| 69 | // Today's date for AI to reference |
| 70 | const todayDate = getTodayDate() |
| 71 | |
| 72 | // Register the resources listing tool for debugging serverless applications |
| 73 | server.tool( |
| 74 | 'list-resources', |
| 75 | '⚠️ MANDATORY PREREQUISITE: You MUST ALWAYS run the list-projects tool FIRST before using this tool! ⚠️\n\n' + |
| 76 | 'Lists all cloud resources associated with a serverless service.\n\n' + |
| 77 | 'REQUIRED WORKFLOW:\n' + |
| 78 | '1. FIRST: Run the list-projects tool to identify all serverless projects in the workspace\n' + |
| 79 | '2. If multiple projects are found, explicitly ask the user which project to use\n' + |
| 80 | '3. ALWAYS confirm with the user which service they want information about, even if only one project is found\n' + |
| 81 | "4. NEVER assume which service the user is interested in - if it is not completely clear from the user's request, you MUST ask for clarification\n" + |
| 82 | '5. Check if stage, region, and profile are specified in the service configuration - if found, USE THESE VALUES in subsequent tool requests\n' + |
| 83 | '6. ONLY THEN use this list-resources tool with the confirmed project information\n\n' + |
| 84 | AWS_CREDENTIALS_ERROR_HANDLING + |
| 85 | '\n\n' + |
| 86 | 'This tool adapts to different infrastructure types: for Serverless Framework or CloudFormation services, it queries the actual deployed resources; for Terraform projects, it provides instructions on how to list resources using terraform state commands. This tool helps identify specific resources (Lambda functions, IAM roles, etc.) that you can then investigate in detail with other specialized tools.', |
| 87 | { |
| 88 | serviceName: z |
| 89 | .string() |
| 90 | .describe( |
| 91 | '⚠️ SERVICE NAME REQUIREMENTS BY PROJECT TYPE ⚠️\n\n' + |
| 92 | '=== FOR SERVERLESS FRAMEWORK PROJECTS ===\n' + |
| 93 | '• FORMAT: "serviceName-stageName" (REQUIRED)\n' + |
| 94 | '• EXAMPLES:\n' + |
| 95 | ' ✓ CORRECT: "my-service-dev", "superapp-platform-prod"\n' + |
| 96 | ' ✗ INCORRECT: "superapp-platform" (missing stage)\n' + |
| 97 | '• The stage name (e.g., "dev", "prod", "staging") MUST be included\n\n' + |
| 98 | 'HOW TO FIND THE STAGE NAME:\n' + |
| 99 | '1. Open the serverless.yml file for the project\n' + |
| 100 | '2. Look for provider.stage in the file (e.g., provider: { stage: "dev" })\n' + |
| 101 | '3. If provider.stage is not specified, use "dev" (the default)\n' + |
| 102 | '4. If you cannot determine the stage, ask the user which stage to check\n\n' + |
| 103 | '=== FOR CLOUDFORMATION PROJECTS ===\n' + |
| 104 | '• You MUST ask the user for the exact CloudFormation stack name\n' + |
| 105 | '• CloudFormation stack names are case-sensitive\n' + |
| 106 | '• Example: "my-application-stack"\n\n' + |
| 107 | '=== FOR TERRAFORM PROJECTS ===\n' + |
| 108 | '• Provide the name of the Terraform project\n' + |
| 109 | '• Example: "my-terraform-project"\n\n' + |
| 110 | 'ALWAYS ask for clarification if you are unsure which service name to use.', |
| 111 | ), |
| 112 | serviceType: z |
no test coverage detected
searching dependent graphs…