@ayga/mcp-client 2.1.0 → 3.1.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/README.md +229 -189
- package/dist/index.js +69 -87
- package/dist/index.js.map +1 -1
- package/dist/tool-definitions.d.ts +40 -0
- package/dist/tool-definitions.d.ts.map +1 -0
- package/dist/tool-definitions.js +126 -0
- package/dist/tool-definitions.js.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,189 +1,229 @@
|
|
|
1
|
-
# Ayga MCP Client (Node.js)
|
|
2
|
-
|
|
3
|
-
Modern, lightweight MCP client
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
1
|
+
# Ayga MCP Client (Node.js) v3.0.0
|
|
2
|
+
|
|
3
|
+
Modern, lightweight MCP client with **6 consolidated AI tools** - optimized for LLM context windows.
|
|
4
|
+
|
|
5
|
+
## What's New in v3.0.0
|
|
6
|
+
|
|
7
|
+
**Context-Optimized Architecture**: Reduced from 40+ individual tools to 6 consolidated tools, saving ~80% context tokens while maintaining full functionality.
|
|
8
|
+
|
|
9
|
+
| Tool | Engines | Default |
|
|
10
|
+
|------|---------|---------|
|
|
11
|
+
| `ask_ai` | perplexity, chatgpt, claude, gemini, copilot, grok, deepseek, deepai | perplexity |
|
|
12
|
+
| `search_web` | google_search, bing_search, duckduckgo, yandex_search, yahoo_search, baidu_search, google_trends, rambler_search, you_search | google_search |
|
|
13
|
+
| `get_social` | instagram_profile, instagram_post, instagram_tag, instagram_geo, tiktok_profile, pinterest_search, reddit_posts, reddit_comments | instagram_profile |
|
|
14
|
+
| `get_video` | youtube_search, youtube_video, youtube_comments, youtube_channel_videos, youtube_channel_about | youtube_search |
|
|
15
|
+
| `translate` | google_translate, bing_translate, yandex_translate | google_translate |
|
|
16
|
+
| `extract` | text_extractor, article_extractor, link_extractor | text_extractor |
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
### Install via npx (recommended)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @ayga/mcp-client
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### VS Code Copilot Configuration
|
|
27
|
+
|
|
28
|
+
Add to `%APPDATA%\Code\User\mcp.json`:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"inputs": [
|
|
33
|
+
{
|
|
34
|
+
"id": "REDIS_API_KEY",
|
|
35
|
+
"type": "promptString",
|
|
36
|
+
"description": "ayga-mcp-client Redis API key",
|
|
37
|
+
"password": true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"servers": {
|
|
41
|
+
"ayga": {
|
|
42
|
+
"type": "stdio",
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["@ayga/mcp-client@latest"],
|
|
45
|
+
"env": {
|
|
46
|
+
"REDIS_API_KEY": "${input:REDIS_API_KEY}"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Claude Desktop Configuration
|
|
54
|
+
|
|
55
|
+
Add to `%APPDATA%\Claude\claude_desktop_config.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"ayga": {
|
|
61
|
+
"command": "npx",
|
|
62
|
+
"args": ["@ayga/mcp-client@latest"],
|
|
63
|
+
"env": {
|
|
64
|
+
"REDIS_API_KEY": "your-api-key-here"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage Examples
|
|
72
|
+
|
|
73
|
+
### Basic Usage (uses default engine)
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
ask_ai query="What is quantum computing?"
|
|
77
|
+
search_web query="latest AI news"
|
|
78
|
+
get_video query="Python tutorials"
|
|
79
|
+
translate query="Hello world"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With Specific Engine
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
ask_ai query="Explain transformers" engine="claude"
|
|
86
|
+
search_web query="weather today" engine="duckduckgo"
|
|
87
|
+
get_social query="@openai" engine="instagram_profile"
|
|
88
|
+
get_video query="dQw4w9WgXcQ" engine="youtube_video"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### With Timeout
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
ask_ai query="Complex analysis" engine="perplexity" timeout=120
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Environment Variables
|
|
98
|
+
|
|
99
|
+
| Variable | Description | Default |
|
|
100
|
+
|----------|-------------|---------|
|
|
101
|
+
| `REDIS_API_KEY` | API key for authentication | (required) |
|
|
102
|
+
| `API_URL` | Backend API URL | https://redis.ayga.tech |
|
|
103
|
+
| `DEFAULT_AI_ENGINE` | Default for ask_ai | perplexity |
|
|
104
|
+
| `DEFAULT_SEARCH_ENGINE` | Default for search_web | google_search |
|
|
105
|
+
| `DEFAULT_SOCIAL_ENGINE` | Default for get_social | instagram_profile |
|
|
106
|
+
| `DEFAULT_VIDEO_ENGINE` | Default for get_video | youtube_search |
|
|
107
|
+
| `DEFAULT_TRANSLATION_ENGINE` | Default for translate | google_translate |
|
|
108
|
+
| `DEFAULT_EXTRACTION_ENGINE` | Default for extract | text_extractor |
|
|
109
|
+
| `DYNAMIC_PARSERS` | Enable dynamic parser loading | true |
|
|
110
|
+
|
|
111
|
+
## Architecture
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
+-------------------------------------+
|
|
115
|
+
| VS Code / Claude Desktop |
|
|
116
|
+
+-----------------+-------------------+
|
|
117
|
+
| MCP stdio
|
|
118
|
+
+-----------------v-------------------+
|
|
119
|
+
| @ayga/mcp-client (Node.js) |
|
|
120
|
+
| - 6 consolidated tools |
|
|
121
|
+
| - 36 parser engines |
|
|
122
|
+
| - JWT authentication |
|
|
123
|
+
+-----------------+-------------------+
|
|
124
|
+
| HTTPS REST API
|
|
125
|
+
+-----------------v-------------------+
|
|
126
|
+
| redis_wrapper (Python/FastAPI) |
|
|
127
|
+
| https://redis.ayga.tech |
|
|
128
|
+
+-----------------+-------------------+
|
|
129
|
+
| Redis Queue
|
|
130
|
+
+-----------------v-------------------+
|
|
131
|
+
| A-Parser (Windows) |
|
|
132
|
+
+-------------------------------------+
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Tool Reference
|
|
136
|
+
|
|
137
|
+
### ask_ai
|
|
138
|
+
Query AI models for answers, analysis, and research.
|
|
139
|
+
|
|
140
|
+
**Engines**: perplexity, chatgpt, claude, gemini, copilot, grok, deepseek, deepai
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
ask_ai query="What are the benefits of Rust?" engine="claude"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### search_web
|
|
147
|
+
Search the web or get trends data.
|
|
148
|
+
|
|
149
|
+
**Engines**: google_search, bing_search, duckduckgo, yandex_search, yahoo_search, baidu_search, google_trends, rambler_search, you_search
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
search_web query="best programming languages 2026"
|
|
153
|
+
search_web query="AI" engine="google_trends"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### get_social
|
|
157
|
+
Get data from social media platforms.
|
|
158
|
+
|
|
159
|
+
**Engines**: instagram_profile, instagram_post, instagram_tag, instagram_geo, tiktok_profile, pinterest_search, reddit_posts, reddit_comments
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
get_social query="@openai" engine="instagram_profile"
|
|
163
|
+
get_social query="machine learning" engine="reddit_posts"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### get_video
|
|
167
|
+
Search and get YouTube content.
|
|
168
|
+
|
|
169
|
+
**Engines**: youtube_search, youtube_video, youtube_comments, youtube_channel_videos, youtube_channel_about
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
get_video query="Python crash course"
|
|
173
|
+
get_video query="https://youtube.com/watch?v=..." engine="youtube_comments"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### translate
|
|
177
|
+
Translate text between languages.
|
|
178
|
+
|
|
179
|
+
**Engines**: google_translate, bing_translate, yandex_translate
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
translate query="Hello, how are you?"
|
|
183
|
+
translate query="Bonjour" engine="yandex_translate"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### extract
|
|
187
|
+
Extract content from web pages.
|
|
188
|
+
|
|
189
|
+
**Engines**: text_extractor, article_extractor, link_extractor
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
extract query="https://example.com/article" engine="article_extractor"
|
|
193
|
+
extract query="https://example.com" engine="link_extractor"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Migration from v2.x
|
|
197
|
+
|
|
198
|
+
**v2.x (40+ tools)**:
|
|
199
|
+
```
|
|
200
|
+
search_perplexity query="What is MCP?"
|
|
201
|
+
search_google_search query="latest news"
|
|
202
|
+
search_youtube_video query="..."
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**v3.x (6 consolidated tools)**:
|
|
206
|
+
```
|
|
207
|
+
ask_ai query="What is MCP?" # uses default: perplexity
|
|
208
|
+
ask_ai query="What is MCP?" engine="perplexity" # explicit
|
|
209
|
+
search_web query="latest news" # uses default: google_search
|
|
210
|
+
get_video query="..." engine="youtube_video"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Getting API Key
|
|
214
|
+
|
|
215
|
+
1. Visit https://redis.ayga.tech
|
|
216
|
+
2. Sign up or log in
|
|
217
|
+
3. Generate API key
|
|
218
|
+
4. Use in configuration
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|
|
223
|
+
|
|
224
|
+
## Links
|
|
225
|
+
|
|
226
|
+
- **API Backend**: https://redis.ayga.tech
|
|
227
|
+
- **Python Version**: https://pypi.org/project/ayga-mcp-client/
|
|
228
|
+
- **GitHub**: https://github.com/ozand/ayga-mcp-nodejs
|
|
229
|
+
- **Issues**: https://github.com/ozand/ayga-mcp-nodejs/issues
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { getRegistry } from "./parser-registry.js";
|
|
6
|
+
import { TOOL_CATEGORIES, getParsersForTool, getDefaultEngine, buildToolSchema } from "./tool-definitions.js";
|
|
6
7
|
// Configuration
|
|
7
8
|
const API_URL = process.env.API_URL || "https://redis.ayga.tech";
|
|
8
9
|
const API_KEY = process.env.REDIS_API_KEY;
|
|
@@ -10,13 +11,11 @@ const API_KEY = process.env.REDIS_API_KEY;
|
|
|
10
11
|
const ENABLE_DYNAMIC = process.env.DYNAMIC_PARSERS !== "false";
|
|
11
12
|
class AygaMCPServer {
|
|
12
13
|
server;
|
|
13
|
-
jwtToken;
|
|
14
|
-
tokenExpiry;
|
|
15
14
|
registry;
|
|
16
15
|
constructor() {
|
|
17
16
|
this.server = new Server({
|
|
18
17
|
name: "ayga-mcp-client",
|
|
19
|
-
version: "
|
|
18
|
+
version: "3.1.0",
|
|
20
19
|
}, {
|
|
21
20
|
capabilities: {
|
|
22
21
|
tools: {},
|
|
@@ -34,46 +33,26 @@ class AygaMCPServer {
|
|
|
34
33
|
const timestamp = new Date().toISOString();
|
|
35
34
|
console.error(`[${timestamp}] [${level.toUpperCase()}] ${message}`);
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
getAuthHeaders() {
|
|
37
|
+
/**
|
|
38
|
+
* Returns authentication headers for API requests.
|
|
39
|
+
* Uses X-API-Key directly - no JWT exchange needed.
|
|
40
|
+
*/
|
|
42
41
|
if (!API_KEY) {
|
|
43
42
|
throw new Error("REDIS_API_KEY environment variable is required");
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
headers: {
|
|
50
|
-
"X-API-Key": API_KEY,
|
|
51
|
-
"Content-Type": "application/json",
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
if (!response.ok) {
|
|
55
|
-
const errorText = await response.text();
|
|
56
|
-
throw new Error(`Auth failed (${response.status}): ${errorText}`);
|
|
57
|
-
}
|
|
58
|
-
const data = await response.json();
|
|
59
|
-
this.jwtToken = data.access_token;
|
|
60
|
-
// Set expiry (default 3600s, use 3000s to be safe)
|
|
61
|
-
this.tokenExpiry = Date.now() + (data.expires_in || 3000) * 1000;
|
|
62
|
-
this.log("JWT token obtained successfully");
|
|
63
|
-
return this.jwtToken;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
this.log(`Authentication error: ${error}`, "error");
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
44
|
+
return {
|
|
45
|
+
"X-API-Key": API_KEY,
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
};
|
|
69
48
|
}
|
|
70
49
|
async submitParserTask(parserId, query, timeout = 60) {
|
|
71
50
|
const parser = await this.registry.getParserById(parserId);
|
|
72
51
|
if (!parser) {
|
|
73
52
|
throw new Error(`Unknown parser: ${parserId}`);
|
|
74
53
|
}
|
|
75
|
-
const token = await this.getJWT();
|
|
76
54
|
const taskId = crypto.randomUUID();
|
|
55
|
+
const headers = this.getAuthHeaders();
|
|
77
56
|
this.log(`Submitting task ${taskId} to parser ${parser.name}`);
|
|
78
57
|
// Prepare task data for A-Parser
|
|
79
58
|
const taskData = JSON.stringify([
|
|
@@ -88,10 +67,7 @@ class AygaMCPServer {
|
|
|
88
67
|
// Submit task to Redis queue
|
|
89
68
|
const submitResponse = await fetch(`${API_URL}/structures/list/aparser_redis_api/lpush`, {
|
|
90
69
|
method: "POST",
|
|
91
|
-
headers
|
|
92
|
-
Authorization: `Bearer ${token}`,
|
|
93
|
-
"Content-Type": "application/json",
|
|
94
|
-
},
|
|
70
|
+
headers,
|
|
95
71
|
body: JSON.stringify({ value: taskData }),
|
|
96
72
|
});
|
|
97
73
|
if (!submitResponse.ok) {
|
|
@@ -100,25 +76,21 @@ class AygaMCPServer {
|
|
|
100
76
|
}
|
|
101
77
|
this.log(`Task ${taskId} submitted, waiting for result (timeout: ${timeout}s)`);
|
|
102
78
|
// Poll for result
|
|
103
|
-
return await this.waitForResult(taskId, timeout,
|
|
79
|
+
return await this.waitForResult(taskId, timeout, headers);
|
|
104
80
|
}
|
|
105
81
|
catch (error) {
|
|
106
82
|
this.log(`Task submission error: ${error}`, "error");
|
|
107
83
|
throw error;
|
|
108
84
|
}
|
|
109
85
|
}
|
|
110
|
-
async waitForResult(taskId, timeout,
|
|
86
|
+
async waitForResult(taskId, timeout, headers) {
|
|
111
87
|
const startTime = Date.now();
|
|
112
88
|
const pollInterval = 2000; // 2 seconds
|
|
113
89
|
let attempts = 0;
|
|
114
90
|
while (Date.now() - startTime < timeout * 1000) {
|
|
115
91
|
attempts++;
|
|
116
92
|
try {
|
|
117
|
-
const response = await fetch(`${API_URL}/kv/aparser_redis_api:${taskId}`, {
|
|
118
|
-
headers: {
|
|
119
|
-
Authorization: `Bearer ${token}`,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
93
|
+
const response = await fetch(`${API_URL}/kv/aparser_redis_api:${taskId}`, { headers });
|
|
122
94
|
if (response.ok) {
|
|
123
95
|
const data = await response.json();
|
|
124
96
|
const result = JSON.parse(data.value);
|
|
@@ -130,6 +102,13 @@ class AygaMCPServer {
|
|
|
130
102
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
131
103
|
continue;
|
|
132
104
|
}
|
|
105
|
+
// Rate limit - wait and retry
|
|
106
|
+
if (response.status === 429) {
|
|
107
|
+
const retryAfter = parseInt(response.headers.get("Retry-After") || "5");
|
|
108
|
+
this.log(`Rate limited, waiting ${retryAfter}s...`, "debug");
|
|
109
|
+
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
133
112
|
// Other errors
|
|
134
113
|
const errorText = await response.text();
|
|
135
114
|
throw new Error(`Failed to get result (${response.status}): ${errorText}`);
|
|
@@ -143,62 +122,59 @@ class AygaMCPServer {
|
|
|
143
122
|
throw new Error(`Timeout waiting for result after ${timeout}s (${attempts} attempts)`);
|
|
144
123
|
}
|
|
145
124
|
setupHandlers() {
|
|
146
|
-
// List available tools
|
|
125
|
+
// List available tools - 6 consolidated tools instead of 40+
|
|
147
126
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
148
127
|
const parsers = await this.registry.getParsers();
|
|
149
|
-
const tools =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
? "Text to translate"
|
|
159
|
-
: "Search query or URL",
|
|
160
|
-
},
|
|
161
|
-
timeout: {
|
|
162
|
-
type: "number",
|
|
163
|
-
description: "Timeout in seconds (default: 60)",
|
|
164
|
-
default: 60,
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
required: ["query"],
|
|
168
|
-
},
|
|
169
|
-
}));
|
|
170
|
-
// Add list_parsers tool
|
|
128
|
+
const tools = [];
|
|
129
|
+
// Build consolidated tools from categories
|
|
130
|
+
for (const toolCat of TOOL_CATEGORIES) {
|
|
131
|
+
const engines = getParsersForTool(toolCat.id, parsers).map(p => p.id);
|
|
132
|
+
if (engines.length > 0) {
|
|
133
|
+
tools.push(buildToolSchema(toolCat, engines));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Add list_parsers utility tool
|
|
171
137
|
tools.push({
|
|
172
138
|
name: "list_parsers",
|
|
173
139
|
description: "List all available parsers with their categories",
|
|
174
140
|
inputSchema: {
|
|
175
141
|
type: "object",
|
|
176
|
-
properties: {
|
|
142
|
+
properties: {
|
|
143
|
+
_placeholder: {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
description: "Placeholder. Always pass true.",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
required: ["_placeholder"],
|
|
177
149
|
},
|
|
178
150
|
});
|
|
151
|
+
this.log(`Registered ${tools.length} consolidated tools (${parsers.length} parsers available)`);
|
|
179
152
|
return { tools };
|
|
180
153
|
});
|
|
181
154
|
// Call tool
|
|
182
155
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
183
156
|
const { name, arguments: args } = request.params;
|
|
184
157
|
try {
|
|
185
|
-
// Handle list_parsers tool
|
|
158
|
+
// Handle list_parsers utility tool
|
|
186
159
|
if (name === "list_parsers") {
|
|
187
|
-
const
|
|
188
|
-
let parsers = await this.registry.getParsers();
|
|
189
|
-
if (category) {
|
|
190
|
-
parsers = parsers.filter((p) => p.category === category);
|
|
191
|
-
}
|
|
160
|
+
const parsers = await this.registry.getParsers();
|
|
192
161
|
const categories = await this.registry.getCategories();
|
|
162
|
+
// Group parsers by consolidated tool
|
|
163
|
+
const toolMapping = {};
|
|
164
|
+
for (const toolCat of TOOL_CATEGORIES) {
|
|
165
|
+
const engines = getParsersForTool(toolCat.id, parsers);
|
|
166
|
+
if (engines.length > 0) {
|
|
167
|
+
toolMapping[toolCat.id] = {
|
|
168
|
+
tool: toolCat.name,
|
|
169
|
+
parsers: engines.map(e => e.id),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
193
173
|
const result = {
|
|
194
174
|
total: parsers.length,
|
|
175
|
+
consolidatedTools: TOOL_CATEGORIES.length,
|
|
195
176
|
categories: categories,
|
|
196
|
-
|
|
197
|
-
id: p.id,
|
|
198
|
-
name: p.name,
|
|
199
|
-
category: p.category,
|
|
200
|
-
description: p.description,
|
|
201
|
-
})),
|
|
177
|
+
toolMapping: toolMapping,
|
|
202
178
|
};
|
|
203
179
|
return {
|
|
204
180
|
content: [
|
|
@@ -209,16 +185,21 @@ class AygaMCPServer {
|
|
|
209
185
|
],
|
|
210
186
|
};
|
|
211
187
|
}
|
|
212
|
-
// Handle
|
|
213
|
-
|
|
214
|
-
|
|
188
|
+
// Handle consolidated tools (ask_ai, search_web, get_social, etc.)
|
|
189
|
+
const toolCat = TOOL_CATEGORIES.find(t => t.id === name);
|
|
190
|
+
if (toolCat) {
|
|
215
191
|
const query = args?.query;
|
|
216
192
|
const timeout = args?.timeout || 60;
|
|
193
|
+
// Get engine - use provided or default
|
|
194
|
+
let engine = args?.engine;
|
|
195
|
+
if (!engine) {
|
|
196
|
+
engine = getDefaultEngine(name);
|
|
197
|
+
}
|
|
217
198
|
if (!query) {
|
|
218
199
|
throw new Error("Query parameter is required");
|
|
219
200
|
}
|
|
220
|
-
this.log(`Executing ${name} with query: ${query.substring(0, 50)}...`);
|
|
221
|
-
const result = await this.submitParserTask(
|
|
201
|
+
this.log(`Executing ${name} with engine=${engine}, query: ${query.substring(0, 50)}...`);
|
|
202
|
+
const result = await this.submitParserTask(engine, query, timeout);
|
|
222
203
|
return {
|
|
223
204
|
content: [
|
|
224
205
|
{
|
|
@@ -228,7 +209,7 @@ class AygaMCPServer {
|
|
|
228
209
|
],
|
|
229
210
|
};
|
|
230
211
|
}
|
|
231
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
212
|
+
throw new Error(`Unknown tool: ${name}. Available: ${TOOL_CATEGORIES.map(t => t.id).join(", ")}, list_parsers`);
|
|
232
213
|
}
|
|
233
214
|
catch (error) {
|
|
234
215
|
this.log(`Tool execution error: ${error}`, "error");
|
|
@@ -268,8 +249,9 @@ class AygaMCPServer {
|
|
|
268
249
|
await this.server.connect(transport);
|
|
269
250
|
// Pre-fetch parsers
|
|
270
251
|
const parsers = await this.registry.getParsers();
|
|
271
|
-
this.log("Ayga MCP Server
|
|
252
|
+
this.log("Ayga MCP Server v3.1.0 started (stateless auth)");
|
|
272
253
|
this.log(`API URL: ${API_URL}`);
|
|
254
|
+
this.log(`Auth: X-API-Key (direct, no JWT exchange)`);
|
|
273
255
|
this.log(`Dynamic loading: ${ENABLE_DYNAMIC ? "enabled" : "disabled"}`);
|
|
274
256
|
this.log(`Total parsers: ${parsers.length}`);
|
|
275
257
|
this.log("Server ready on stdio transport");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,EACH,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
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,EACH,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAE/B,gBAAgB;AAChB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,yBAAyB,CAAC;AACjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AAE1C,gEAAgE;AAChE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,OAAO,CAAC;AAS/D,MAAM,aAAa;IACP,MAAM,CAAS;IACf,QAAQ,CAAiB;IAEjC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACpB;YACA,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,OAAO;SACf,EACD;YACI,YAAY,EAAE;gBACV,KAAK,EAAE,EAAE;aACZ;SACJ,CACJ,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;YACxB,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,O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;QAErC,oBAAoB;QACpB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAEjD,IAAI,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACtD,IAAI,CAAC,GAAG,CAAC,oBAAoB,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,kBAAkB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,cAAc;AACd,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;AACnC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated Tool Definitions
|
|
3
|
+
*
|
|
4
|
+
* Instead of 40+ individual tools, we define 6 category-based tools
|
|
5
|
+
* with an optional 'engine' parameter for specific parser selection.
|
|
6
|
+
*/
|
|
7
|
+
import type { ParserConfig } from "./parsers.js";
|
|
8
|
+
/**
|
|
9
|
+
* Tool category configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolCategory {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
categories: string[];
|
|
16
|
+
defaultEngine: string;
|
|
17
|
+
defaultEnvVar: string;
|
|
18
|
+
queryDescription: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Consolidated tool definitions
|
|
22
|
+
*/
|
|
23
|
+
export declare const TOOL_CATEGORIES: ToolCategory[];
|
|
24
|
+
/**
|
|
25
|
+
* Get parsers for a tool category
|
|
26
|
+
*/
|
|
27
|
+
export declare function getParsersForTool(toolId: string, allParsers: ParserConfig[]): ParserConfig[];
|
|
28
|
+
/**
|
|
29
|
+
* Get default engine for a tool, checking ENV first
|
|
30
|
+
*/
|
|
31
|
+
export declare function getDefaultEngine(toolId: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Find which tool a parser belongs to
|
|
34
|
+
*/
|
|
35
|
+
export declare function findToolForParser(parserId: string, allParsers: ParserConfig[]): ToolCategory | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Build MCP tool schema for a consolidated tool
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildToolSchema(tool: ToolCategory, availableEngines: string[]): object;
|
|
40
|
+
//# sourceMappingURL=tool-definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-definitions.d.ts","sourceRoot":"","sources":["../src/tool-definitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,EAuDzC,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EAAE,GAC3B,YAAY,EAAE,CAKhB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,YAAY,EAAE,GAC3B,YAAY,GAAG,SAAS,CAK1B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,YAAY,EAClB,gBAAgB,EAAE,MAAM,EAAE,GAC3B,MAAM,CAwBR"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated Tool Definitions
|
|
3
|
+
*
|
|
4
|
+
* Instead of 40+ individual tools, we define 6 category-based tools
|
|
5
|
+
* with an optional 'engine' parameter for specific parser selection.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Consolidated tool definitions
|
|
9
|
+
*/
|
|
10
|
+
export const TOOL_CATEGORIES = [
|
|
11
|
+
{
|
|
12
|
+
id: "ask_ai",
|
|
13
|
+
name: "Ask AI",
|
|
14
|
+
description: "Query AI models like Perplexity, ChatGPT, Claude, Gemini for answers and analysis",
|
|
15
|
+
categories: ["AI Chat"],
|
|
16
|
+
defaultEngine: "perplexity",
|
|
17
|
+
defaultEnvVar: "DEFAULT_AI_ENGINE",
|
|
18
|
+
queryDescription: "Question or prompt for the AI model",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "search_web",
|
|
22
|
+
name: "Web Search",
|
|
23
|
+
description: "Search the web using Google, Bing, DuckDuckGo, Yandex or get Google Trends data",
|
|
24
|
+
categories: ["Search Engines", "Google Trends"],
|
|
25
|
+
defaultEngine: "google_search",
|
|
26
|
+
defaultEnvVar: "DEFAULT_SEARCH_ENGINE",
|
|
27
|
+
queryDescription: "Search query",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "get_social",
|
|
31
|
+
name: "Social Media",
|
|
32
|
+
description: "Get data from social platforms: Instagram profiles/posts, TikTok, Reddit posts/comments, Pinterest",
|
|
33
|
+
categories: ["Instagram", "TikTok", "Reddit", "Pinterest"],
|
|
34
|
+
defaultEngine: "instagram_profile",
|
|
35
|
+
defaultEnvVar: "DEFAULT_SOCIAL_ENGINE",
|
|
36
|
+
queryDescription: "Username, URL, or search query",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "get_video",
|
|
40
|
+
name: "Video Data",
|
|
41
|
+
description: "Search YouTube videos, get video details, comments, or channel information",
|
|
42
|
+
categories: ["YouTube"],
|
|
43
|
+
defaultEngine: "youtube_search",
|
|
44
|
+
defaultEnvVar: "DEFAULT_VIDEO_ENGINE",
|
|
45
|
+
queryDescription: "Search query or video/channel URL",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "translate",
|
|
49
|
+
name: "Translate",
|
|
50
|
+
description: "Translate text using Google Translate, DeepL, Bing, or Yandex",
|
|
51
|
+
categories: ["Translation"],
|
|
52
|
+
defaultEngine: "google_translate",
|
|
53
|
+
defaultEnvVar: "DEFAULT_TRANSLATION_ENGINE",
|
|
54
|
+
queryDescription: "Text to translate",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "extract",
|
|
58
|
+
name: "Extract Content",
|
|
59
|
+
description: "Extract text, articles, or links from web pages",
|
|
60
|
+
categories: ["HTML Content"],
|
|
61
|
+
defaultEngine: "text_extractor",
|
|
62
|
+
defaultEnvVar: "DEFAULT_EXTRACTION_ENGINE",
|
|
63
|
+
queryDescription: "URL of the web page",
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* Get parsers for a tool category
|
|
68
|
+
*/
|
|
69
|
+
export function getParsersForTool(toolId, allParsers) {
|
|
70
|
+
const tool = TOOL_CATEGORIES.find(t => t.id === toolId);
|
|
71
|
+
if (!tool)
|
|
72
|
+
return [];
|
|
73
|
+
return allParsers.filter(p => tool.categories.includes(p.category));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get default engine for a tool, checking ENV first
|
|
77
|
+
*/
|
|
78
|
+
export function getDefaultEngine(toolId) {
|
|
79
|
+
const tool = TOOL_CATEGORIES.find(t => t.id === toolId);
|
|
80
|
+
if (!tool)
|
|
81
|
+
return "";
|
|
82
|
+
// Check environment variable first
|
|
83
|
+
const envValue = process.env[tool.defaultEnvVar];
|
|
84
|
+
if (envValue) {
|
|
85
|
+
return envValue;
|
|
86
|
+
}
|
|
87
|
+
return tool.defaultEngine;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Find which tool a parser belongs to
|
|
91
|
+
*/
|
|
92
|
+
export function findToolForParser(parserId, allParsers) {
|
|
93
|
+
const parser = allParsers.find(p => p.id === parserId);
|
|
94
|
+
if (!parser)
|
|
95
|
+
return undefined;
|
|
96
|
+
return TOOL_CATEGORIES.find(t => t.categories.includes(parser.category));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build MCP tool schema for a consolidated tool
|
|
100
|
+
*/
|
|
101
|
+
export function buildToolSchema(tool, availableEngines) {
|
|
102
|
+
return {
|
|
103
|
+
name: tool.id,
|
|
104
|
+
description: tool.description,
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
query: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: tool.queryDescription,
|
|
111
|
+
},
|
|
112
|
+
engine: {
|
|
113
|
+
type: "string",
|
|
114
|
+
description: `Specific engine to use. Available: ${availableEngines.join(", ")}. Default: ${getDefaultEngine(tool.id)}`,
|
|
115
|
+
enum: availableEngines,
|
|
116
|
+
},
|
|
117
|
+
timeout: {
|
|
118
|
+
type: "number",
|
|
119
|
+
description: "Timeout in seconds (default: 60)",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
required: ["query"],
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=tool-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC3B,IAAkB,EAClB,gBAA0B;IAE1B,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,EAAE;QACb,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,KAAK,EAAE;oBACH,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,IAAI,CAAC,gBAAgB;iBACrC;gBACD,MAAM,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sCAAsC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBACvH,IAAI,EAAE,gBAAgB;iBACzB;gBACD,OAAO,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kCAAkC;iBAClD;aACJ;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACtB;KACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ayga/mcp-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "MCP client
|
|
1
|
+
{
|
|
2
|
+
"name": "@ayga/mcp-client",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "MCP client with 6 consolidated AI tools - stateless X-API-Key auth, no JWT exchange needed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
7
7
|
"model-context-protocol",
|