mcp-researchpowerpack 3.6.9
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/README.md +635 -0
- package/dist/clients/reddit.d.ts +74 -0
- package/dist/clients/reddit.d.ts.map +1 -0
- package/dist/clients/reddit.js +305 -0
- package/dist/clients/reddit.js.map +1 -0
- package/dist/clients/research.d.ts +67 -0
- package/dist/clients/research.d.ts.map +1 -0
- package/dist/clients/research.js +252 -0
- package/dist/clients/research.js.map +1 -0
- package/dist/clients/scraper.d.ts +71 -0
- package/dist/clients/scraper.d.ts.map +1 -0
- package/dist/clients/scraper.js +321 -0
- package/dist/clients/scraper.js.map +1 -0
- package/dist/clients/search.d.ts +62 -0
- package/dist/clients/search.d.ts.map +1 -0
- package/dist/clients/search.js +219 -0
- package/dist/clients/search.js.map +1 -0
- package/dist/config/index.d.ts +62 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +142 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +40 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +305 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +81 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +6 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/yaml/tools.yaml +130 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +271 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/deep-research.d.ts +64 -0
- package/dist/schemas/deep-research.d.ts.map +1 -0
- package/dist/schemas/deep-research.js +224 -0
- package/dist/schemas/deep-research.js.map +1 -0
- package/dist/schemas/scrape-links.d.ts +32 -0
- package/dist/schemas/scrape-links.d.ts.map +1 -0
- package/dist/schemas/scrape-links.js +34 -0
- package/dist/schemas/scrape-links.js.map +1 -0
- package/dist/schemas/web-search.d.ts +22 -0
- package/dist/schemas/web-search.d.ts.map +1 -0
- package/dist/schemas/web-search.js +21 -0
- package/dist/schemas/web-search.js.map +1 -0
- package/dist/services/file-attachment.d.ts +30 -0
- package/dist/services/file-attachment.d.ts.map +1 -0
- package/dist/services/file-attachment.js +199 -0
- package/dist/services/file-attachment.js.map +1 -0
- package/dist/services/llm-processor.d.ts +27 -0
- package/dist/services/llm-processor.d.ts.map +1 -0
- package/dist/services/llm-processor.js +179 -0
- package/dist/services/llm-processor.js.map +1 -0
- package/dist/services/markdown-cleaner.d.ts +8 -0
- package/dist/services/markdown-cleaner.d.ts.map +1 -0
- package/dist/services/markdown-cleaner.js +44 -0
- package/dist/services/markdown-cleaner.js.map +1 -0
- package/dist/tools/definitions.d.ts +16 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +17 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/reddit.d.ts +14 -0
- package/dist/tools/reddit.d.ts.map +1 -0
- package/dist/tools/reddit.js +213 -0
- package/dist/tools/reddit.js.map +1 -0
- package/dist/tools/registry.d.ts +71 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +242 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/research.d.ts +14 -0
- package/dist/tools/research.d.ts.map +1 -0
- package/dist/tools/research.js +194 -0
- package/dist/tools/research.js.map +1 -0
- package/dist/tools/scrape.d.ts +14 -0
- package/dist/tools/scrape.d.ts.map +1 -0
- package/dist/tools/scrape.js +201 -0
- package/dist/tools/scrape.js.map +1 -0
- package/dist/tools/search.d.ts +10 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +137 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/utils.d.ts +105 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +159 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/utils/concurrency.d.ts +29 -0
- package/dist/utils/concurrency.d.ts.map +1 -0
- package/dist/utils/concurrency.js +73 -0
- package/dist/utils/concurrency.js.map +1 -0
- package/dist/utils/errors.d.ts +77 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +335 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +39 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +57 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/markdown-formatter.d.ts +5 -0
- package/dist/utils/markdown-formatter.d.ts.map +1 -0
- package/dist/utils/markdown-formatter.js +15 -0
- package/dist/utils/markdown-formatter.js.map +1 -0
- package/dist/utils/response.d.ts +88 -0
- package/dist/utils/response.d.ts.map +1 -0
- package/dist/utils/response.js +151 -0
- package/dist/utils/response.js.map +1 -0
- package/dist/utils/url-aggregator.d.ts +90 -0
- package/dist/utils/url-aggregator.d.ts.map +1 -0
- package/dist/utils/url-aggregator.js +502 -0
- package/dist/utils/url-aggregator.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +60 -0
- package/dist/version.js.map +1 -0
- package/dist/worker.d.ts +17 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +53 -0
- package/dist/worker.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reddit.d.ts","sourceRoot":"","sources":["../../src/tools/reddit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0DH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAMD,UAAU,qBAAqB;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAyBD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,WAAW,SAAM,EACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,CAmHjB"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reddit Tools - Search and Fetch
|
|
3
|
+
* NEVER throws - always returns structured response for graceful degradation
|
|
4
|
+
*/
|
|
5
|
+
import { SearchClient } from '../clients/search.js';
|
|
6
|
+
import { RedditClient, calculateCommentAllocation } from '../clients/reddit.js';
|
|
7
|
+
import { aggregateAndRankReddit, generateRedditEnhancedOutput } from '../utils/url-aggregator.js';
|
|
8
|
+
import { REDDIT } from '../config/index.js';
|
|
9
|
+
import { classifyError } from '../utils/errors.js';
|
|
10
|
+
import { createLLMProcessor, processContentWithLLM } from '../services/llm-processor.js';
|
|
11
|
+
import { getToolConfig } from '../config/loader.js';
|
|
12
|
+
import { mcpLog, formatSuccess, formatError, formatBatchHeader, TOKEN_BUDGETS, } from './utils.js';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Formatters
|
|
15
|
+
// ============================================================================
|
|
16
|
+
function formatComments(comments) {
|
|
17
|
+
let md = '';
|
|
18
|
+
for (const c of comments) {
|
|
19
|
+
const indent = ' '.repeat(c.depth);
|
|
20
|
+
const op = c.isOP ? ' **[OP]**' : '';
|
|
21
|
+
const score = c.score >= 0 ? `+${c.score}` : `${c.score}`;
|
|
22
|
+
md += `${indent}- **u/${c.author}**${op} _(${score})_\n`;
|
|
23
|
+
const bodyLines = c.body.split('\n').map(line => `${indent} ${line}`).join('\n');
|
|
24
|
+
md += `${bodyLines}\n\n`;
|
|
25
|
+
}
|
|
26
|
+
return md;
|
|
27
|
+
}
|
|
28
|
+
function formatPost(result, fetchComments) {
|
|
29
|
+
const { post, comments, allocatedComments } = result;
|
|
30
|
+
let md = `## ${post.title}\n\n`;
|
|
31
|
+
md += `**r/${post.subreddit}** • u/${post.author} • ⬆️ ${post.score} • 💬 ${post.commentCount} comments\n`;
|
|
32
|
+
md += `🔗 ${post.url}\n\n`;
|
|
33
|
+
if (post.body) {
|
|
34
|
+
md += `### Post Content\n\n${post.body}\n\n`;
|
|
35
|
+
}
|
|
36
|
+
if (fetchComments && comments.length > 0) {
|
|
37
|
+
md += `### Top Comments (${comments.length}/${post.commentCount} shown, allocated: ${allocatedComments})\n\n`;
|
|
38
|
+
md += formatComments(comments);
|
|
39
|
+
}
|
|
40
|
+
else if (!fetchComments) {
|
|
41
|
+
md += `_Comments not fetched (fetch_comments=false)_\n\n`;
|
|
42
|
+
}
|
|
43
|
+
return md;
|
|
44
|
+
}
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Search Reddit Handler
|
|
47
|
+
// ============================================================================
|
|
48
|
+
export async function handleSearchReddit(queries, apiKey, dateAfter) {
|
|
49
|
+
try {
|
|
50
|
+
const limited = queries.slice(0, 50);
|
|
51
|
+
const client = new SearchClient(apiKey);
|
|
52
|
+
const results = await client.searchRedditMultiple(limited, dateAfter);
|
|
53
|
+
// Check if any results were found
|
|
54
|
+
let totalResults = 0;
|
|
55
|
+
for (const items of results.values()) {
|
|
56
|
+
totalResults += items.length;
|
|
57
|
+
}
|
|
58
|
+
if (totalResults === 0) {
|
|
59
|
+
return formatError({
|
|
60
|
+
code: 'NO_RESULTS',
|
|
61
|
+
message: `No results found for any of the ${limited.length} queries`,
|
|
62
|
+
toolName: 'search_reddit',
|
|
63
|
+
howToFix: [
|
|
64
|
+
'Try broader or simpler search terms',
|
|
65
|
+
'Check spelling of technical terms',
|
|
66
|
+
'Remove date filters if using them',
|
|
67
|
+
],
|
|
68
|
+
alternatives: [
|
|
69
|
+
'web_search(keywords=[...]) for general web results',
|
|
70
|
+
'deep_research(questions=[...]) for synthesized analysis',
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Aggregate and rank results by CTR
|
|
75
|
+
const aggregation = aggregateAndRankReddit(results, 3);
|
|
76
|
+
// Generate enhanced output with consensus highlighting AND per-query raw results
|
|
77
|
+
return generateRedditEnhancedOutput(aggregation, limited, results);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const structuredError = classifyError(error);
|
|
81
|
+
return formatError({
|
|
82
|
+
code: structuredError.code,
|
|
83
|
+
message: structuredError.message,
|
|
84
|
+
retryable: structuredError.retryable,
|
|
85
|
+
toolName: 'search_reddit',
|
|
86
|
+
howToFix: ['Verify SERPER_API_KEY is set correctly'],
|
|
87
|
+
alternatives: ['web_search(keywords=[...]) as backup'],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Get extraction suffix from YAML config (fallback to hardcoded if not found)
|
|
92
|
+
function getExtractionSuffix() {
|
|
93
|
+
const config = getToolConfig('get_reddit_post');
|
|
94
|
+
return config?.limits?.extraction_suffix || `
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
⚠️ IMPORTANT: Extract and synthesize the key insights, opinions, and recommendations from these Reddit discussions. Focus on:
|
|
98
|
+
- Common themes and consensus across posts
|
|
99
|
+
- Specific recommendations with context
|
|
100
|
+
- Contrasting viewpoints and debates
|
|
101
|
+
- Real-world experiences and lessons learned
|
|
102
|
+
- Technical details and implementation tips
|
|
103
|
+
|
|
104
|
+
Be comprehensive but concise. Prioritize actionable insights.
|
|
105
|
+
|
|
106
|
+
---`;
|
|
107
|
+
}
|
|
108
|
+
function enhanceExtractionInstruction(instruction) {
|
|
109
|
+
const base = instruction || 'Extract key insights, recommendations, and community consensus from these Reddit discussions.';
|
|
110
|
+
return `${base}\n\n${getExtractionSuffix()}`;
|
|
111
|
+
}
|
|
112
|
+
export async function handleGetRedditPosts(urls, clientId, clientSecret, maxComments = 100, options = {}) {
|
|
113
|
+
try {
|
|
114
|
+
const { fetchComments = true, maxCommentsOverride, use_llm = false, what_to_extract } = options;
|
|
115
|
+
if (urls.length < REDDIT.MIN_POSTS) {
|
|
116
|
+
return formatError({
|
|
117
|
+
code: 'MIN_POSTS',
|
|
118
|
+
message: `Minimum ${REDDIT.MIN_POSTS} Reddit posts required. Received: ${urls.length}`,
|
|
119
|
+
toolName: 'get_reddit_post',
|
|
120
|
+
howToFix: [`Add at least ${REDDIT.MIN_POSTS - urls.length} more Reddit URL(s)`],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (urls.length > REDDIT.MAX_POSTS) {
|
|
124
|
+
return formatError({
|
|
125
|
+
code: 'MAX_POSTS',
|
|
126
|
+
message: `Maximum ${REDDIT.MAX_POSTS} Reddit posts allowed. Received: ${urls.length}`,
|
|
127
|
+
toolName: 'get_reddit_post',
|
|
128
|
+
howToFix: [`Remove ${urls.length - REDDIT.MAX_POSTS} URL(s) and retry`],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const allocation = calculateCommentAllocation(urls.length);
|
|
132
|
+
const commentsPerPost = fetchComments ? (maxCommentsOverride || allocation.perPostCapped) : 0;
|
|
133
|
+
const totalBatches = Math.ceil(urls.length / REDDIT.BATCH_SIZE);
|
|
134
|
+
const client = new RedditClient(clientId, clientSecret);
|
|
135
|
+
const batchResult = await client.batchGetPosts(urls, commentsPerPost, fetchComments);
|
|
136
|
+
const results = batchResult.results;
|
|
137
|
+
// Initialize LLM processor if needed
|
|
138
|
+
const llmProcessor = use_llm ? createLLMProcessor() : null;
|
|
139
|
+
const tokensPerUrl = use_llm ? Math.floor(TOKEN_BUDGETS.RESEARCH / urls.length) : 0;
|
|
140
|
+
const enhancedInstruction = use_llm ? enhanceExtractionInstruction(what_to_extract) : undefined;
|
|
141
|
+
let successful = 0;
|
|
142
|
+
let failed = 0;
|
|
143
|
+
let llmErrors = 0;
|
|
144
|
+
const contents = [];
|
|
145
|
+
for (const [url, result] of results) {
|
|
146
|
+
if (result instanceof Error) {
|
|
147
|
+
failed++;
|
|
148
|
+
contents.push(`## ❌ Failed: ${url}\n\n_${result.message}_`);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
successful++;
|
|
152
|
+
let postContent = formatPost(result, fetchComments);
|
|
153
|
+
// Apply LLM extraction per-URL if enabled
|
|
154
|
+
if (use_llm && llmProcessor) {
|
|
155
|
+
mcpLog('info', `[${successful}/${urls.length}] Applying LLM extraction to ${url}`, 'reddit');
|
|
156
|
+
const llmResult = await processContentWithLLM(postContent, { use_llm: true, what_to_extract: enhancedInstruction, max_tokens: tokensPerUrl }, llmProcessor);
|
|
157
|
+
if (llmResult.processed) {
|
|
158
|
+
postContent = `## LLM Analysis: ${result.post.title}\n\n**r/${result.post.subreddit}** • u/${result.post.author} • ⬆️ ${result.post.score} • 💬 ${result.post.commentCount} comments\n🔗 ${result.post.url}\n\n${llmResult.content}`;
|
|
159
|
+
mcpLog('debug', `[${successful}/${urls.length}] LLM extraction complete`, 'reddit');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
llmErrors++;
|
|
163
|
+
mcpLog('warning', `[${successful}/${urls.length}] LLM extraction failed: ${llmResult.error || 'unknown'}`, 'reddit');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
contents.push(postContent);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Build 70/20/10 response
|
|
170
|
+
const batchHeader = formatBatchHeader({
|
|
171
|
+
title: `Reddit Posts`,
|
|
172
|
+
totalItems: urls.length,
|
|
173
|
+
successful,
|
|
174
|
+
failed,
|
|
175
|
+
...(fetchComments ? { extras: { 'Comments/post': commentsPerPost } } : {}),
|
|
176
|
+
...(use_llm ? { tokensPerItem: tokensPerUrl } : {}),
|
|
177
|
+
batches: totalBatches,
|
|
178
|
+
});
|
|
179
|
+
const statusExtras = [];
|
|
180
|
+
if (batchResult.rateLimitHits > 0) {
|
|
181
|
+
statusExtras.push(`⚠️ ${batchResult.rateLimitHits} rate limit retries`);
|
|
182
|
+
}
|
|
183
|
+
if (use_llm && !llmProcessor) {
|
|
184
|
+
statusExtras.push('⚠️ LLM unavailable (OPENROUTER_API_KEY not set)');
|
|
185
|
+
}
|
|
186
|
+
else if (llmErrors > 0) {
|
|
187
|
+
statusExtras.push(`⚠️ ${llmErrors} LLM extraction failures`);
|
|
188
|
+
}
|
|
189
|
+
const nextSteps = [
|
|
190
|
+
successful > 0 ? 'Research further: deep_research(questions=[{question: "Based on Reddit discussion..."}])' : null,
|
|
191
|
+
failed > 0 ? 'Retry failed URLs individually' : null,
|
|
192
|
+
'Search related topics: search_reddit(queries=[...related terms...])',
|
|
193
|
+
].filter(Boolean);
|
|
194
|
+
const extraStatus = statusExtras.length > 0 ? `\n${statusExtras.join(' | ')}` : '';
|
|
195
|
+
return formatSuccess({
|
|
196
|
+
title: `Reddit Posts Fetched (${successful}/${urls.length})`,
|
|
197
|
+
summary: batchHeader + extraStatus,
|
|
198
|
+
data: contents.join('\n\n---\n\n'),
|
|
199
|
+
nextSteps,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
const structuredError = classifyError(error);
|
|
204
|
+
return formatError({
|
|
205
|
+
code: structuredError.code,
|
|
206
|
+
message: structuredError.message,
|
|
207
|
+
retryable: structuredError.retryable,
|
|
208
|
+
toolName: 'get_reddit_post',
|
|
209
|
+
howToFix: ['Verify REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRET are set'],
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=reddit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reddit.js","sourceRoot":"","sources":["../../src/tools/reddit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAiC,MAAM,sBAAsB,CAAC;AAC/G,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,oBAA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,OAAO;YAChC,SAAS,EAAE,eAAe,CAAC,SAAS;YACpC,QAAQ,EAAE,iBAAiB;YAC3B,QAAQ,EAAE,CAAC,0DAA0D,CAAC;SACvE,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler Registry - Central tool registration and execution
|
|
3
|
+
* Eliminates repetitive if/else routing with declarative registration
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { type Capabilities } from '../config/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* MCP-compliant tool result with index signature for SDK compatibility
|
|
9
|
+
*/
|
|
10
|
+
export interface CallToolResult {
|
|
11
|
+
content: Array<{
|
|
12
|
+
type: 'text';
|
|
13
|
+
text: string;
|
|
14
|
+
}>;
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for a registered tool
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolRegistration {
|
|
22
|
+
name: string;
|
|
23
|
+
capability?: keyof Capabilities;
|
|
24
|
+
schema: z.ZodSchema;
|
|
25
|
+
handler: (params: unknown) => Promise<string>;
|
|
26
|
+
postValidate?: (params: unknown) => string | undefined;
|
|
27
|
+
transformResponse?: (result: string) => {
|
|
28
|
+
content: string;
|
|
29
|
+
isError?: boolean;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registry type
|
|
34
|
+
*/
|
|
35
|
+
export type ToolRegistry = Record<string, ToolRegistration>;
|
|
36
|
+
/**
|
|
37
|
+
* Central registry of all MCP tools
|
|
38
|
+
*/
|
|
39
|
+
export declare const toolRegistry: ToolRegistry;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a tool by name with full middleware chain
|
|
42
|
+
*
|
|
43
|
+
* Middleware steps:
|
|
44
|
+
* 1. Lookup tool in registry (throw McpError if not found)
|
|
45
|
+
* 2. Check capability (return error response if missing)
|
|
46
|
+
* 3. Validate params with Zod (return error response if invalid)
|
|
47
|
+
* 4. Execute handler (catch and format any errors)
|
|
48
|
+
* 5. Transform response if needed
|
|
49
|
+
*
|
|
50
|
+
* @param name - Tool name from request
|
|
51
|
+
* @param args - Raw arguments from request
|
|
52
|
+
* @param capabilities - Current capabilities from getCapabilities()
|
|
53
|
+
* @returns MCP-compliant tool result
|
|
54
|
+
*/
|
|
55
|
+
export declare function executeTool(name: string, args: unknown, capabilities: Capabilities): Promise<CallToolResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Get list of all registered tool names
|
|
58
|
+
*/
|
|
59
|
+
export declare function getRegisteredToolNames(): string[];
|
|
60
|
+
/**
|
|
61
|
+
* Check if a tool is registered
|
|
62
|
+
*/
|
|
63
|
+
export declare function isToolRegistered(name: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get tool capabilities for logging
|
|
66
|
+
*/
|
|
67
|
+
export declare function getToolCapabilities(): {
|
|
68
|
+
enabled: string[];
|
|
69
|
+
disabled: string[];
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAY,MAAM,KAAK,CAAC;AAGlC,OAAO,EAAmD,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBxG;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,YAAY,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAChF;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAgF5D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YA+C1B,CAAC;AAMF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,cAAc,CAAC,CAuEzB;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAe/E"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler Registry - Central tool registration and execution
|
|
3
|
+
* Eliminates repetitive if/else routing with declarative registration
|
|
4
|
+
*/
|
|
5
|
+
import { z, ZodError } from 'zod';
|
|
6
|
+
import { McpError, ErrorCode as McpErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { parseEnv, getCapabilities, getMissingEnvMessage } from '../config/index.js';
|
|
8
|
+
import { classifyError, createToolErrorFromStructured } from '../utils/errors.js';
|
|
9
|
+
// Import schemas
|
|
10
|
+
import { deepResearchParamsSchema } from '../schemas/deep-research.js';
|
|
11
|
+
import { scrapeLinksParamsSchema } from '../schemas/scrape-links.js';
|
|
12
|
+
import { webSearchParamsSchema } from '../schemas/web-search.js';
|
|
13
|
+
// Import handlers
|
|
14
|
+
import { handleSearchReddit, handleGetRedditPosts } from './reddit.js';
|
|
15
|
+
import { handleDeepResearch } from './research.js';
|
|
16
|
+
import { handleScrapeLinks } from './scrape.js';
|
|
17
|
+
import { handleWebSearch } from './search.js';
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Schemas for Simple Tools (inline definitions)
|
|
20
|
+
// ============================================================================
|
|
21
|
+
const searchRedditParamsSchema = z.object({
|
|
22
|
+
queries: z.array(z.string()).min(10).max(50),
|
|
23
|
+
date_after: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
const getRedditPostParamsSchema = z.object({
|
|
26
|
+
urls: z.array(z.string()).min(2).max(50),
|
|
27
|
+
fetch_comments: z.boolean().default(true),
|
|
28
|
+
max_comments: z.number().default(100),
|
|
29
|
+
use_llm: z.boolean().default(false),
|
|
30
|
+
what_to_extract: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Handler Wrappers
|
|
34
|
+
// ============================================================================
|
|
35
|
+
const env = parseEnv();
|
|
36
|
+
/**
|
|
37
|
+
* Wrapper for search_reddit handler
|
|
38
|
+
*/
|
|
39
|
+
async function searchRedditHandler(params) {
|
|
40
|
+
const p = params;
|
|
41
|
+
return handleSearchReddit(p.queries, env.SEARCH_API_KEY || '', p.date_after);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Wrapper for get_reddit_post handler
|
|
45
|
+
*/
|
|
46
|
+
async function getRedditPostHandler(params) {
|
|
47
|
+
const p = params;
|
|
48
|
+
return handleGetRedditPosts(p.urls, env.REDDIT_CLIENT_ID || '', env.REDDIT_CLIENT_SECRET || '', p.max_comments, {
|
|
49
|
+
fetchComments: p.fetch_comments,
|
|
50
|
+
maxCommentsOverride: p.max_comments !== 100 ? p.max_comments : undefined,
|
|
51
|
+
use_llm: p.use_llm,
|
|
52
|
+
what_to_extract: p.what_to_extract,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wrapper for deep_research handler
|
|
57
|
+
*/
|
|
58
|
+
async function deepResearchHandler(params) {
|
|
59
|
+
const { content } = await handleDeepResearch(params);
|
|
60
|
+
return content;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Wrapper for scrape_links handler
|
|
64
|
+
*/
|
|
65
|
+
async function scrapeLinksHandler(params) {
|
|
66
|
+
const { content } = await handleScrapeLinks(params);
|
|
67
|
+
return content;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Wrapper for web_search handler
|
|
71
|
+
*/
|
|
72
|
+
async function webSearchHandler(params) {
|
|
73
|
+
const { content } = await handleWebSearch(params);
|
|
74
|
+
return content;
|
|
75
|
+
}
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Tool Registry
|
|
78
|
+
// ============================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Central registry of all MCP tools
|
|
81
|
+
*/
|
|
82
|
+
export const toolRegistry = {
|
|
83
|
+
search_reddit: {
|
|
84
|
+
name: 'search_reddit',
|
|
85
|
+
capability: 'search',
|
|
86
|
+
schema: searchRedditParamsSchema,
|
|
87
|
+
handler: searchRedditHandler,
|
|
88
|
+
},
|
|
89
|
+
get_reddit_post: {
|
|
90
|
+
name: 'get_reddit_post',
|
|
91
|
+
capability: 'reddit',
|
|
92
|
+
schema: getRedditPostParamsSchema,
|
|
93
|
+
handler: getRedditPostHandler,
|
|
94
|
+
},
|
|
95
|
+
deep_research: {
|
|
96
|
+
name: 'deep_research',
|
|
97
|
+
capability: 'deepResearch',
|
|
98
|
+
schema: deepResearchParamsSchema,
|
|
99
|
+
handler: deepResearchHandler,
|
|
100
|
+
transformResponse: (result) => ({
|
|
101
|
+
content: result,
|
|
102
|
+
isError: result.includes('# ❌ Error'),
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
scrape_links: {
|
|
106
|
+
name: 'scrape_links',
|
|
107
|
+
capability: 'scraping',
|
|
108
|
+
schema: scrapeLinksParamsSchema,
|
|
109
|
+
handler: scrapeLinksHandler,
|
|
110
|
+
transformResponse: (result) => ({
|
|
111
|
+
content: result,
|
|
112
|
+
isError: result.includes('# ❌ Scraping Failed'),
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
web_search: {
|
|
116
|
+
name: 'web_search',
|
|
117
|
+
capability: 'search',
|
|
118
|
+
schema: webSearchParamsSchema,
|
|
119
|
+
handler: webSearchHandler,
|
|
120
|
+
transformResponse: (result) => ({
|
|
121
|
+
content: result,
|
|
122
|
+
isError: result.includes('# ❌ web_search'),
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Execute Tool (Main Entry Point)
|
|
128
|
+
// ============================================================================
|
|
129
|
+
/**
|
|
130
|
+
* Execute a tool by name with full middleware chain
|
|
131
|
+
*
|
|
132
|
+
* Middleware steps:
|
|
133
|
+
* 1. Lookup tool in registry (throw McpError if not found)
|
|
134
|
+
* 2. Check capability (return error response if missing)
|
|
135
|
+
* 3. Validate params with Zod (return error response if invalid)
|
|
136
|
+
* 4. Execute handler (catch and format any errors)
|
|
137
|
+
* 5. Transform response if needed
|
|
138
|
+
*
|
|
139
|
+
* @param name - Tool name from request
|
|
140
|
+
* @param args - Raw arguments from request
|
|
141
|
+
* @param capabilities - Current capabilities from getCapabilities()
|
|
142
|
+
* @returns MCP-compliant tool result
|
|
143
|
+
*/
|
|
144
|
+
export async function executeTool(name, args, capabilities) {
|
|
145
|
+
// Step 1: Lookup tool
|
|
146
|
+
const tool = toolRegistry[name];
|
|
147
|
+
if (!tool) {
|
|
148
|
+
throw new McpError(McpErrorCode.MethodNotFound, `Method not found: ${name}. Available tools: ${Object.keys(toolRegistry).join(', ')}`);
|
|
149
|
+
}
|
|
150
|
+
// Step 2: Check capability
|
|
151
|
+
if (tool.capability && !capabilities[tool.capability]) {
|
|
152
|
+
return {
|
|
153
|
+
content: [{ type: 'text', text: getMissingEnvMessage(tool.capability) }],
|
|
154
|
+
isError: true,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// Step 3: Validate params with Zod
|
|
158
|
+
let validatedParams;
|
|
159
|
+
try {
|
|
160
|
+
validatedParams = tool.schema.parse(args);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error instanceof ZodError) {
|
|
164
|
+
const issues = error.issues
|
|
165
|
+
.map((i) => `- **${i.path.join('.') || 'root'}**: ${i.message}`)
|
|
166
|
+
.join('\n');
|
|
167
|
+
return {
|
|
168
|
+
content: [{ type: 'text', text: `# ❌ Validation Error\n\n${issues}` }],
|
|
169
|
+
isError: true,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// Non-Zod validation error
|
|
173
|
+
const structured = classifyError(error);
|
|
174
|
+
return createToolErrorFromStructured(structured);
|
|
175
|
+
}
|
|
176
|
+
// Step 3.5: Optional post-validation
|
|
177
|
+
if (tool.postValidate) {
|
|
178
|
+
const postError = tool.postValidate(validatedParams);
|
|
179
|
+
if (postError) {
|
|
180
|
+
return {
|
|
181
|
+
content: [{ type: 'text', text: `# ❌ Validation Error\n\n${postError}` }],
|
|
182
|
+
isError: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Step 4: Execute handler
|
|
187
|
+
let result;
|
|
188
|
+
try {
|
|
189
|
+
result = await tool.handler(validatedParams);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
// Handler threw (shouldn't happen if handlers follow "never throw" pattern)
|
|
193
|
+
const structured = classifyError(error);
|
|
194
|
+
return createToolErrorFromStructured(structured);
|
|
195
|
+
}
|
|
196
|
+
// Step 5: Transform response
|
|
197
|
+
if (tool.transformResponse) {
|
|
198
|
+
const transformed = tool.transformResponse(result);
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: 'text', text: transformed.content }],
|
|
201
|
+
isError: transformed.isError,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// Default: success response
|
|
205
|
+
return {
|
|
206
|
+
content: [{ type: 'text', text: result }],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// ============================================================================
|
|
210
|
+
// Utility Functions
|
|
211
|
+
// ============================================================================
|
|
212
|
+
/**
|
|
213
|
+
* Get list of all registered tool names
|
|
214
|
+
*/
|
|
215
|
+
export function getRegisteredToolNames() {
|
|
216
|
+
return Object.keys(toolRegistry);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Check if a tool is registered
|
|
220
|
+
*/
|
|
221
|
+
export function isToolRegistered(name) {
|
|
222
|
+
return name in toolRegistry;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get tool capabilities for logging
|
|
226
|
+
*/
|
|
227
|
+
export function getToolCapabilities() {
|
|
228
|
+
const caps = getCapabilities();
|
|
229
|
+
const enabled = [];
|
|
230
|
+
const disabled = [];
|
|
231
|
+
for (const [name, tool] of Object.entries(toolRegistry)) {
|
|
232
|
+
const capKey = tool.capability;
|
|
233
|
+
if (!capKey || caps[capKey]) {
|
|
234
|
+
enabled.push(name);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
disabled.push(name);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { enabled, disabled };
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,QAA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,WAAW,CAAC,OAAO,EAAE,CAAC;YACtD,OAAO,EAAE,WAAW,CAAC,OAAO;SAC7B,CAAC;IACJ,CAAC;IAED,4BAA4B;IAC5B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,IAAI,YAAY,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;QAC/B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Research Tool Handler - Batch processing with dynamic token allocation
|
|
3
|
+
* Implements robust error handling that NEVER crashes
|
|
4
|
+
*/
|
|
5
|
+
import type { DeepResearchParams } from '../schemas/deep-research.js';
|
|
6
|
+
/**
|
|
7
|
+
* Handle deep research request
|
|
8
|
+
* NEVER throws - always returns a valid response
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleDeepResearch(params: DeepResearchParams): Promise<{
|
|
11
|
+
content: string;
|
|
12
|
+
structuredContent: object;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=research.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../../src/tools/research.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AA8CtE;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC,CA6KzD"}
|