@chanaka_nakandala/integration-agent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/cache/file-cache.d.ts +10 -0
- package/dist/cache/file-cache.d.ts.map +1 -0
- package/dist/cache/file-cache.js +79 -0
- package/dist/cache/file-cache.js.map +1 -0
- package/dist/cli/init-command.d.ts +2 -0
- package/dist/cli/init-command.d.ts.map +1 -0
- package/dist/cli/init-command.js +115 -0
- package/dist/cli/init-command.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +493 -0
- package/dist/index.js.map +1 -0
- package/dist/scrapers/docs-scraper.d.ts +28 -0
- package/dist/scrapers/docs-scraper.d.ts.map +1 -0
- package/dist/scrapers/docs-scraper.js +200 -0
- package/dist/scrapers/docs-scraper.js.map +1 -0
- package/dist/search/keyword-search.d.ts +39 -0
- package/dist/search/keyword-search.d.ts.map +1 -0
- package/dist/search/keyword-search.js +127 -0
- package/dist/search/keyword-search.js.map +1 -0
- package/dist/tools/code-generation-tool.d.ts +33 -0
- package/dist/tools/code-generation-tool.d.ts.map +1 -0
- package/dist/tools/code-generation-tool.js +62 -0
- package/dist/tools/code-generation-tool.js.map +1 -0
- package/dist/tools/search-result-formatter.d.ts +27 -0
- package/dist/tools/search-result-formatter.d.ts.map +1 -0
- package/dist/tools/search-result-formatter.js +89 -0
- package/dist/tools/search-result-formatter.js.map +1 -0
- package/dist/tools/search-tool.d.ts +9 -0
- package/dist/tools/search-tool.d.ts.map +1 -0
- package/dist/tools/search-tool.js +32 -0
- package/dist/tools/search-tool.js.map +1 -0
- package/dist/tools/template-loader.d.ts +54 -0
- package/dist/tools/template-loader.d.ts.map +1 -0
- package/dist/tools/template-loader.js +148 -0
- package/dist/tools/template-loader.js.map +1 -0
- package/dist/types/search.d.ts +21 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/search.js +2 -0
- package/dist/types/search.js.map +1 -0
- package/package.json +63 -0
- package/templates/README.md +98 -0
- package/templates/authenticate/curl.template +97 -0
- package/templates/authenticate/java.template +155 -0
- package/templates/authenticate/python.template +111 -0
- package/templates/authenticate/typescript.template +98 -0
- package/templates/create_menu/curl.template +145 -0
- package/templates/create_menu/java.template +285 -0
- package/templates/create_menu/python.template +159 -0
- package/templates/create_menu/typescript.template +184 -0
- package/templates/receive_order/curl.template +138 -0
- package/templates/receive_order/java.template +263 -0
- package/templates/receive_order/python.template +157 -0
- package/templates/receive_order/typescript.template +194 -0
- package/templates/update_item_availability/curl.template +143 -0
- package/templates/update_item_availability/java.template +279 -0
- package/templates/update_item_availability/python.template +203 -0
- package/templates/update_item_availability/typescript.template +194 -0
- package/templates/update_order_status/curl.template +138 -0
- package/templates/update_order_status/java.template +202 -0
- package/templates/update_order_status/python.template +142 -0
- package/templates/update_order_status/typescript.template +139 -0
package/dist/index.js
ADDED
@@ -0,0 +1,493 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
4
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
5
|
+
import { initCommand } from './cli/init-command.js';
|
6
|
+
import { SearchTool } from './tools/search-tool.js';
|
7
|
+
import { CodeGenerationTool } from './tools/code-generation-tool.js';
|
8
|
+
import { FileCache } from './cache/file-cache.js';
|
9
|
+
import { DocsScraper } from './scrapers/docs-scraper.js';
|
10
|
+
// Check for CLI commands
|
11
|
+
const args = process.argv.slice(2);
|
12
|
+
if (args[0] === 'init') {
|
13
|
+
initCommand()
|
14
|
+
.then(() => process.exit(0))
|
15
|
+
.catch((error) => {
|
16
|
+
console.error('Init failed:', error);
|
17
|
+
process.exit(1);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
else if (args[0] === 'mcp-server' || args.length === 0) {
|
21
|
+
// Start MCP server
|
22
|
+
const server = new Server({
|
23
|
+
name: 'grubtech-integration-support',
|
24
|
+
version: '1.0.0',
|
25
|
+
}, {
|
26
|
+
capabilities: {
|
27
|
+
tools: {},
|
28
|
+
prompts: {},
|
29
|
+
},
|
30
|
+
});
|
31
|
+
// Initialize tools and cache
|
32
|
+
const cache = new FileCache();
|
33
|
+
const searchTool = new SearchTool();
|
34
|
+
const codeGenerationTool = new CodeGenerationTool();
|
35
|
+
const docsScraper = new DocsScraper(cache);
|
36
|
+
// Track scraping state
|
37
|
+
let isScrapingInProgress = false;
|
38
|
+
let lastScrapedAt = null;
|
39
|
+
// Register MCP prompt handlers
|
40
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
41
|
+
return {
|
42
|
+
prompts: [
|
43
|
+
{
|
44
|
+
name: 'get_started',
|
45
|
+
description: 'WORKFLOW GUIDE: Start here if this is your first time using the agent. Provides a comprehensive 4-step workflow guide explaining how to use all tools and prompts. Shows example workflows and important notes. Use this prompt when the user asks "how do I use this" or "how does this work" or when starting a new integration project.',
|
46
|
+
arguments: [],
|
47
|
+
},
|
48
|
+
{
|
49
|
+
name: 'grubtech_api_question',
|
50
|
+
description: 'ANSWER QUESTIONS: Use this prompt to answer specific questions about Grubtech API integration. Automatically searches documentation and provides context-aware answers. CRITICAL: Only returns information from official Grubtech documentation - never makes up information. If information is not found in documentation, explicitly states it. Use this when user asks specific "how to" questions like "How do I authenticate?" or "What is the order webhook payload structure?" PREREQUISITE: Documentation must be scraped first using scrape_grubtech_docs tool.',
|
51
|
+
arguments: [
|
52
|
+
{
|
53
|
+
name: 'question',
|
54
|
+
description: 'The specific question about Grubtech API integration (e.g., "How do I authenticate with API keys?" or "What is the menu sync endpoint?")',
|
55
|
+
required: true,
|
56
|
+
},
|
57
|
+
],
|
58
|
+
},
|
59
|
+
{
|
60
|
+
name: 'integration_guide',
|
61
|
+
description: 'STEP-BY-STEP GUIDES: Generates detailed step-by-step integration guides for specific operations. Searches documentation and creates structured guides with implementation steps. Best used when user needs a complete walkthrough for implementing a specific feature. Example: "Give me a guide for menu synchronization" or "Show me how to handle order webhooks step-by-step". PREREQUISITE: Documentation must be scraped first.',
|
62
|
+
arguments: [
|
63
|
+
{
|
64
|
+
name: 'operation',
|
65
|
+
description: 'The integration operation to create a guide for. Options: "authentication" (API keys, OAuth), "menu_sync" (uploading menus), "order_handling" (receiving order webhooks), "item_availability" (updating item stock)',
|
66
|
+
required: true,
|
67
|
+
},
|
68
|
+
],
|
69
|
+
},
|
70
|
+
],
|
71
|
+
};
|
72
|
+
});
|
73
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
74
|
+
if (request.params.name === 'get_started') {
|
75
|
+
return {
|
76
|
+
messages: [
|
77
|
+
{
|
78
|
+
role: 'user',
|
79
|
+
content: {
|
80
|
+
type: 'text',
|
81
|
+
text: `Welcome to the Grubtech Integration Support Agent! This MCP server helps you integrate with Grubtech APIs.
|
82
|
+
|
83
|
+
## 🚀 Quick Start Workflow
|
84
|
+
|
85
|
+
**Step 1: Download Documentation**
|
86
|
+
First, run the \`scrape_grubtech_docs\` tool to download and cache all Grubtech API documentation from https://docs.grubtech.io
|
87
|
+
|
88
|
+
\`\`\`
|
89
|
+
Use tool: scrape_grubtech_docs
|
90
|
+
Parameters: (none required, or force: true to refresh)
|
91
|
+
\`\`\`
|
92
|
+
|
93
|
+
This downloads 210+ documentation pages covering:
|
94
|
+
- Authentication (API Key, OAuth)
|
95
|
+
- Ordering Platforms (Store, Menu, Order Integration)
|
96
|
+
- POS Applications
|
97
|
+
- Logistic Platforms
|
98
|
+
- Data API, gData
|
99
|
+
- And more...
|
100
|
+
|
101
|
+
**Step 2: Search Documentation**
|
102
|
+
Use the \`search_grubtech_docs\` tool to find relevant information:
|
103
|
+
|
104
|
+
\`\`\`
|
105
|
+
Use tool: search_grubtech_docs
|
106
|
+
Parameters:
|
107
|
+
- query: "your search keywords"
|
108
|
+
- integrationPhase: (optional) AUTH, MENU_SYNC, ORDER_CREATION, ORDER_STATUS, GO_LIVE
|
109
|
+
\`\`\`
|
110
|
+
|
111
|
+
**Step 3: Ask Questions**
|
112
|
+
Use the \`grubtech_api_question\` prompt to ask specific questions:
|
113
|
+
|
114
|
+
\`\`\`
|
115
|
+
Use prompt: grubtech_api_question
|
116
|
+
Parameters:
|
117
|
+
- question: "your question about Grubtech API"
|
118
|
+
\`\`\`
|
119
|
+
|
120
|
+
**Step 4: Generate Code**
|
121
|
+
Use the \`generate_integration_code\` tool to create code templates:
|
122
|
+
|
123
|
+
\`\`\`
|
124
|
+
Use tool: generate_integration_code
|
125
|
+
Parameters:
|
126
|
+
- operation: authenticate | create_menu | receive_order | update_order_status | update_item_availability
|
127
|
+
- language: typescript | python | java | curl
|
128
|
+
\`\`\`
|
129
|
+
|
130
|
+
## 📚 Available Tools
|
131
|
+
|
132
|
+
1. **scrape_grubtech_docs** - Downloads all documentation (run this first!)
|
133
|
+
2. **search_grubtech_docs** - Search cached documentation by keywords
|
134
|
+
3. **generate_integration_code** - Generate code snippets in 4 languages
|
135
|
+
|
136
|
+
## 💡 Available Prompts
|
137
|
+
|
138
|
+
1. **get_started** (this prompt) - Workflow guide
|
139
|
+
2. **grubtech_api_question** - Ask questions about Grubtech API
|
140
|
+
3. **integration_guide** - Get step-by-step guides for specific operations
|
141
|
+
|
142
|
+
## 🎯 Example Workflow
|
143
|
+
|
144
|
+
\`\`\`
|
145
|
+
1. "Use scrape_grubtech_docs tool to download documentation"
|
146
|
+
2. "Search for 'authentication' using search_grubtech_docs"
|
147
|
+
3. "Ask: How do I authenticate with the Grubtech API?"
|
148
|
+
4. "Generate TypeScript authentication code"
|
149
|
+
\`\`\`
|
150
|
+
|
151
|
+
## ⚠️ Important Notes
|
152
|
+
|
153
|
+
- **Always run scrape_grubtech_docs first** if you haven't already
|
154
|
+
- Documentation is cached for 24 hours
|
155
|
+
- All answers are based ONLY on official Grubtech documentation
|
156
|
+
- If information is not in the documentation, the agent will tell you
|
157
|
+
|
158
|
+
Ready to start? Run the scrape_grubtech_docs tool now!`,
|
159
|
+
},
|
160
|
+
},
|
161
|
+
],
|
162
|
+
};
|
163
|
+
}
|
164
|
+
if (request.params.name === 'grubtech_api_question') {
|
165
|
+
const question = request.params.arguments?.question || '';
|
166
|
+
// Search for relevant documentation
|
167
|
+
const searchResults = await searchTool.search(question);
|
168
|
+
let context = '';
|
169
|
+
if (searchResults.results.length === 0) {
|
170
|
+
context = 'No relevant documentation found in the Grubtech documentation portal.';
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
context = 'Relevant documentation from Grubtech:\n\n';
|
174
|
+
searchResults.results.forEach((result, idx) => {
|
175
|
+
context += `### Source ${idx + 1}: ${result.title}\n`;
|
176
|
+
context += `URL: ${result.sourceUrl}\n`;
|
177
|
+
context += `${result.snippet}\n\n`;
|
178
|
+
});
|
179
|
+
}
|
180
|
+
return {
|
181
|
+
messages: [
|
182
|
+
{
|
183
|
+
role: 'user',
|
184
|
+
content: {
|
185
|
+
type: 'text',
|
186
|
+
text: `You are a Grubtech API integration assistant. Answer the following question ONLY using the provided documentation context. If the answer is not in the documentation, explicitly state "This information is not available in the Grubtech documentation portal."
|
187
|
+
|
188
|
+
CRITICAL RULES:
|
189
|
+
- DO NOT make up or assume any information
|
190
|
+
- DO NOT use your general knowledge about APIs
|
191
|
+
- ONLY use information from the documentation context below
|
192
|
+
- If the documentation is insufficient, say so
|
193
|
+
|
194
|
+
Question: ${question}
|
195
|
+
|
196
|
+
Documentation Context:
|
197
|
+
${context}
|
198
|
+
|
199
|
+
Please provide an accurate answer based ONLY on the documentation context above.`,
|
200
|
+
},
|
201
|
+
},
|
202
|
+
],
|
203
|
+
};
|
204
|
+
}
|
205
|
+
if (request.params.name === 'integration_guide') {
|
206
|
+
const operation = request.params.arguments?.operation || '';
|
207
|
+
// Map operation to search query
|
208
|
+
const queryMap = {
|
209
|
+
'authentication': 'authentication API key token',
|
210
|
+
'menu_sync': 'menu synchronization upload',
|
211
|
+
'order_handling': 'order webhook receive',
|
212
|
+
'item_availability': 'item availability update',
|
213
|
+
};
|
214
|
+
const query = queryMap[operation] || operation;
|
215
|
+
const searchResults = await searchTool.search(query);
|
216
|
+
let context = '';
|
217
|
+
if (searchResults.results.length === 0) {
|
218
|
+
context = `No documentation found for ${operation} in the Grubtech documentation portal.`;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
context = 'Step-by-step guide from Grubtech documentation:\n\n';
|
222
|
+
searchResults.results.forEach((result, idx) => {
|
223
|
+
context += `### Step ${idx + 1}: ${result.title}\n`;
|
224
|
+
context += `${result.snippet}\n\n`;
|
225
|
+
if (result.sourceUrl) {
|
226
|
+
context += `Reference: ${result.sourceUrl}\n\n`;
|
227
|
+
}
|
228
|
+
});
|
229
|
+
}
|
230
|
+
return {
|
231
|
+
messages: [
|
232
|
+
{
|
233
|
+
role: 'user',
|
234
|
+
content: {
|
235
|
+
type: 'text',
|
236
|
+
text: `Create a step-by-step integration guide for ${operation} using ONLY the documentation provided below.
|
237
|
+
|
238
|
+
CRITICAL RULES:
|
239
|
+
- Use ONLY information from the documentation context
|
240
|
+
- Do NOT invent steps or details
|
241
|
+
- If the documentation is incomplete, note what is missing
|
242
|
+
|
243
|
+
Documentation Context:
|
244
|
+
${context}
|
245
|
+
|
246
|
+
Please create a clear, step-by-step guide based on the documentation.`,
|
247
|
+
},
|
248
|
+
},
|
249
|
+
],
|
250
|
+
};
|
251
|
+
}
|
252
|
+
throw new Error(`Unknown prompt: ${request.params.name}`);
|
253
|
+
});
|
254
|
+
// Register MCP tool handlers
|
255
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
256
|
+
return {
|
257
|
+
tools: [
|
258
|
+
{
|
259
|
+
name: 'scrape_grubtech_docs',
|
260
|
+
description: 'PREREQUISITE TOOL - RUN FIRST: Downloads and caches all 210+ documentation pages from https://docs.grubtech.io covering Authentication, Ordering Platforms, POS Applications, Logistics, Data API, gData, and more. This tool MUST be run before using any other tools or prompts. Takes 2-3 minutes to complete. Documentation is cached for 24 hours. WHEN TO USE: (1) At the start of any new conversation/session, (2) When search returns "No documentation is cached", (3) Once per day to refresh documentation. Set force=true to refresh even if cache exists.',
|
261
|
+
inputSchema: {
|
262
|
+
type: 'object',
|
263
|
+
properties: {
|
264
|
+
force: {
|
265
|
+
type: 'boolean',
|
266
|
+
description: 'Set to true to force re-scrape even if fresh cache exists (less than 24 hours old). Default: false. Use force=true when you need the latest documentation or if cached data seems outdated.',
|
267
|
+
},
|
268
|
+
},
|
269
|
+
},
|
270
|
+
},
|
271
|
+
{
|
272
|
+
name: 'search_grubtech_docs',
|
273
|
+
description: 'SEARCH DOCUMENTATION: Searches through 14,000+ cached documentation chunks using keyword matching and returns the top 5 most relevant results with source URLs and relevance scores. Use this tool to find specific information before answering questions. WHEN TO USE: (1) Before answering any technical question about Grubtech API, (2) To find endpoint details, payload structures, or authentication methods, (3) To gather context for code generation. RETURNS: Formatted search results with titles, URLs, relevance percentages, and content snippets. Each result includes anti-hallucination warnings. PREREQUISITE: Must run scrape_grubtech_docs first.',
|
274
|
+
inputSchema: {
|
275
|
+
type: 'object',
|
276
|
+
properties: {
|
277
|
+
query: {
|
278
|
+
type: 'string',
|
279
|
+
description: 'Search keywords or natural language question (e.g., "API authentication", "menu upload endpoint", "order webhook payload structure"). The search uses keyword matching across titles, headings, and content.',
|
280
|
+
},
|
281
|
+
integrationPhase: {
|
282
|
+
type: 'string',
|
283
|
+
enum: ['AUTH', 'MENU_SYNC', 'ORDER_CREATION', 'ORDER_STATUS', 'GO_LIVE'],
|
284
|
+
description: 'OPTIONAL: Filter results by integration phase. Use AUTH for authentication topics, MENU_SYNC for menu operations, ORDER_CREATION for receiving orders, ORDER_STATUS for order updates, GO_LIVE for production deployment. Leave empty to search all documentation.',
|
285
|
+
},
|
286
|
+
},
|
287
|
+
required: ['query'],
|
288
|
+
},
|
289
|
+
},
|
290
|
+
{
|
291
|
+
name: 'generate_integration_code',
|
292
|
+
description: 'CODE GENERATOR: Generates production-ready code snippets with complete error handling, type definitions, and inline documentation. Available in 4 languages: TypeScript (Node.js with fetch), Python (requests library), Java (HttpClient), and cURL (shell scripts). Each template includes placeholder markers like {{API_KEY}} that need to be replaced with actual values. WHEN TO USE: After finding documentation via search, when user requests code examples, or when implementing specific integration operations. Returns fully working code with comments and example usage. NOTE: Code is template-based, not generated from documentation - always verify against current API docs.',
|
293
|
+
inputSchema: {
|
294
|
+
type: 'object',
|
295
|
+
properties: {
|
296
|
+
operation: {
|
297
|
+
type: 'string',
|
298
|
+
enum: [
|
299
|
+
'authenticate',
|
300
|
+
'create_menu',
|
301
|
+
'receive_order',
|
302
|
+
'update_order_status',
|
303
|
+
'update_item_availability',
|
304
|
+
],
|
305
|
+
description: 'The integration operation: "authenticate" (get API access token), "create_menu" (upload menu data to Grubtech), "receive_order" (handle incoming order webhooks), "update_order_status" (update order lifecycle), "update_item_availability" (toggle menu item stock)',
|
306
|
+
},
|
307
|
+
language: {
|
308
|
+
type: 'string',
|
309
|
+
enum: ['typescript', 'python', 'java', 'curl'],
|
310
|
+
description: 'Programming language: "typescript" (Node.js 18+ with fetch API), "python" (Python 3.8+ with requests), "java" (Java 11+ with HttpClient), "curl" (command-line for testing)',
|
311
|
+
},
|
312
|
+
},
|
313
|
+
required: ['operation', 'language'],
|
314
|
+
},
|
315
|
+
},
|
316
|
+
],
|
317
|
+
};
|
318
|
+
});
|
319
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
320
|
+
const args = request.params.arguments;
|
321
|
+
if (request.params.name === 'scrape_grubtech_docs') {
|
322
|
+
const force = args?.force || false;
|
323
|
+
// Check if already scraping
|
324
|
+
if (isScrapingInProgress) {
|
325
|
+
return {
|
326
|
+
content: [
|
327
|
+
{
|
328
|
+
type: 'text',
|
329
|
+
text: 'Documentation scraping is already in progress. Please wait...',
|
330
|
+
},
|
331
|
+
],
|
332
|
+
};
|
333
|
+
}
|
334
|
+
// Check if recent cache exists
|
335
|
+
if (!force) {
|
336
|
+
const docs = await cache.getAllCachedDocs();
|
337
|
+
if (docs.length > 0 && lastScrapedAt) {
|
338
|
+
const hoursSinceLastScrape = (Date.now() - lastScrapedAt.getTime()) / (1000 * 60 * 60);
|
339
|
+
if (hoursSinceLastScrape < 24) {
|
340
|
+
return {
|
341
|
+
content: [
|
342
|
+
{
|
343
|
+
type: 'text',
|
344
|
+
text: `Documentation cache is fresh (${Math.round(hoursSinceLastScrape * 10) / 10} hours old, ${docs.length} documents). Use force:true to re-scrape.`,
|
345
|
+
},
|
346
|
+
],
|
347
|
+
};
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
// Start scraping
|
352
|
+
isScrapingInProgress = true;
|
353
|
+
try {
|
354
|
+
console.error('Starting documentation scrape...');
|
355
|
+
const chunks = await docsScraper.scrapeDocumentation();
|
356
|
+
lastScrapedAt = new Date();
|
357
|
+
isScrapingInProgress = false;
|
358
|
+
return {
|
359
|
+
content: [
|
360
|
+
{
|
361
|
+
type: 'text',
|
362
|
+
text: `Successfully scraped ${chunks.length} documentation chunks from Grubtech portal. Documentation is now available for search and queries.`,
|
363
|
+
},
|
364
|
+
],
|
365
|
+
};
|
366
|
+
}
|
367
|
+
catch (error) {
|
368
|
+
isScrapingInProgress = false;
|
369
|
+
return {
|
370
|
+
content: [
|
371
|
+
{
|
372
|
+
type: 'text',
|
373
|
+
text: `Failed to scrape documentation: ${error.message}`,
|
374
|
+
},
|
375
|
+
],
|
376
|
+
isError: true,
|
377
|
+
};
|
378
|
+
}
|
379
|
+
}
|
380
|
+
if (request.params.name === 'search_grubtech_docs') {
|
381
|
+
const response = await searchTool.search(args?.query || '', args?.integrationPhase);
|
382
|
+
// Check if cache is empty
|
383
|
+
if (response.results.length === 0 && response.metadata.totalResults === 0) {
|
384
|
+
return {
|
385
|
+
content: [
|
386
|
+
{
|
387
|
+
type: 'text',
|
388
|
+
text: 'No documentation is cached. Please run the "scrape_grubtech_docs" tool first to download documentation from the Grubtech portal.',
|
389
|
+
},
|
390
|
+
],
|
391
|
+
};
|
392
|
+
}
|
393
|
+
// Format response with clear instructions
|
394
|
+
let resultText = `# Search Results for: "${response.metadata.query}"\n\n`;
|
395
|
+
if (response.results.length === 0) {
|
396
|
+
resultText += `No relevant documentation found for your query.\n\n`;
|
397
|
+
resultText += `Searched ${response.metadata.totalResults} cached documents.\n\n`;
|
398
|
+
resultText += `IMPORTANT: Answer "I could not find information about this in the Grubtech documentation" - do not make up information.`;
|
399
|
+
}
|
400
|
+
else {
|
401
|
+
resultText += `Found ${response.results.length} relevant results:\n\n`;
|
402
|
+
response.results.forEach((result, idx) => {
|
403
|
+
resultText += `## Result ${idx + 1}: ${result.title}\n`;
|
404
|
+
resultText += `**Source:** ${result.sourceUrl}\n`;
|
405
|
+
resultText += `**Relevance:** ${(result.relevanceScore * 100).toFixed(1)}%\n\n`;
|
406
|
+
resultText += `${result.snippet}\n\n`;
|
407
|
+
resultText += `---\n\n`;
|
408
|
+
});
|
409
|
+
resultText += `\nIMPORTANT: Base your answer ONLY on the documentation above. If the answer is not in these results, say "This specific information is not available in the Grubtech documentation I have access to."`;
|
410
|
+
}
|
411
|
+
return {
|
412
|
+
content: [
|
413
|
+
{
|
414
|
+
type: 'text',
|
415
|
+
text: resultText,
|
416
|
+
},
|
417
|
+
],
|
418
|
+
};
|
419
|
+
}
|
420
|
+
if (request.params.name === 'generate_integration_code') {
|
421
|
+
const result = await codeGenerationTool.generate(args?.operation, args?.language);
|
422
|
+
if ('error' in result) {
|
423
|
+
return {
|
424
|
+
content: [
|
425
|
+
{
|
426
|
+
type: 'text',
|
427
|
+
text: JSON.stringify(result, null, 2),
|
428
|
+
},
|
429
|
+
],
|
430
|
+
isError: true,
|
431
|
+
};
|
432
|
+
}
|
433
|
+
return {
|
434
|
+
content: [
|
435
|
+
{
|
436
|
+
type: 'text',
|
437
|
+
text: `Generated ${result.operation} code in ${result.language}:\n\n\`\`\`${result.language}\n${result.code}\n\`\`\`\n\nPlaceholders to replace: ${result.metadata.placeholders.join(', ')}`,
|
438
|
+
},
|
439
|
+
],
|
440
|
+
};
|
441
|
+
}
|
442
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
443
|
+
});
|
444
|
+
// Graceful shutdown handlers
|
445
|
+
process.on('SIGINT', async () => {
|
446
|
+
console.error('Shutting down MCP server (SIGINT)...');
|
447
|
+
process.exit(0);
|
448
|
+
});
|
449
|
+
process.on('SIGTERM', async () => {
|
450
|
+
console.error('Shutting down MCP server (SIGTERM)...');
|
451
|
+
process.exit(0);
|
452
|
+
});
|
453
|
+
// Start MCP server with STDIO transport
|
454
|
+
async function main() {
|
455
|
+
try {
|
456
|
+
const transport = new StdioServerTransport();
|
457
|
+
await server.connect(transport);
|
458
|
+
console.error('🚀 Grubtech Integration Support MCP server started');
|
459
|
+
console.error('');
|
460
|
+
console.error('📖 Capabilities: Tools & Prompts');
|
461
|
+
console.error('');
|
462
|
+
console.error('💡 Available Prompts:');
|
463
|
+
console.error(' - get_started: Learn how to use this agent (START HERE!)');
|
464
|
+
console.error(' - grubtech_api_question: Ask questions about Grubtech API');
|
465
|
+
console.error(' - integration_guide: Get step-by-step integration guides');
|
466
|
+
console.error('');
|
467
|
+
console.error('🔧 Available Tools:');
|
468
|
+
console.error(' - scrape_grubtech_docs: Download documentation (run this first)');
|
469
|
+
console.error(' - search_grubtech_docs: Search cached documentation');
|
470
|
+
console.error(' - generate_integration_code: Generate code templates');
|
471
|
+
console.error('');
|
472
|
+
console.error('✨ Quick Start:');
|
473
|
+
console.error(' 1. Use "get_started" prompt to see the workflow guide');
|
474
|
+
console.error(' 2. Run "scrape_grubtech_docs" tool to download 210+ pages');
|
475
|
+
console.error(' 3. Search and ask questions about Grubtech API');
|
476
|
+
console.error('');
|
477
|
+
}
|
478
|
+
catch (error) {
|
479
|
+
console.error('Failed to start MCP server:', error);
|
480
|
+
process.exit(1);
|
481
|
+
}
|
482
|
+
}
|
483
|
+
main().catch((error) => {
|
484
|
+
console.error('Unhandled error in main:', error);
|
485
|
+
process.exit(1);
|
486
|
+
});
|
487
|
+
}
|
488
|
+
else {
|
489
|
+
console.error(`Unknown command: ${args[0]}`);
|
490
|
+
console.log('Usage: npx @grubtech/integration-agent [init|mcp-server]');
|
491
|
+
process.exit(1);
|
492
|
+
}
|
493
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,yBAAyB;AACzB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE;SACV,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC;KAAM,IAAI,IAAI,C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AI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { FileCache } from '../cache/file-cache.js';
|
2
|
+
import type { DocumentChunk } from '@grubtech/agent-core';
|
3
|
+
export declare class DocsScraper {
|
4
|
+
private axios;
|
5
|
+
private cache;
|
6
|
+
private visited;
|
7
|
+
private lastRequestTime;
|
8
|
+
private readonly RATE_LIMIT_MS;
|
9
|
+
private readonly BASE_URL;
|
10
|
+
private readonly START_URL;
|
11
|
+
constructor(cache: FileCache);
|
12
|
+
private rateLimit;
|
13
|
+
private urlToKey;
|
14
|
+
private shouldFollowLink;
|
15
|
+
/**
|
16
|
+
* Extract all navigation links from the sidebar
|
17
|
+
*/
|
18
|
+
private getAllDocumentationLinks;
|
19
|
+
/**
|
20
|
+
* Scrape a single page and extract content chunks
|
21
|
+
*/
|
22
|
+
scrapePage(url: string): Promise<DocumentChunk[]>;
|
23
|
+
/**
|
24
|
+
* Main scraping method - extracts all documentation links and scrapes each page
|
25
|
+
*/
|
26
|
+
scrapeDocumentation(): Promise<DocumentChunk[]>;
|
27
|
+
}
|
28
|
+
//# sourceMappingURL=docs-scraper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"docs-scraper.d.ts","sourceRoot":"","sources":["../../src/scrapers/docs-scraper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAO;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmD;gBAEjE,KAAK,EAAE,SAAS;YAYd,SAAS;IAWvB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;YACW,wBAAwB;IAmCtC;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAiGvD;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CA0BtD"}
|