@node2flow/gemini-file-search-rag-mcp 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 +157 -0
- package/dist/gemini-client.d.ts +41 -0
- package/dist/gemini-client.d.ts.map +1 -0
- package/dist/gemini-client.js +157 -0
- package/dist/gemini-client.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +190 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +119 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +392 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +258 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/worker.d.ts +11 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +74 -0
- package/dist/worker.js.map +1 -0
- package/package.json +51 -0
package/dist/tools.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini RAG File Search - MCP Tool Definitions (12 tools)
|
|
3
|
+
*/
|
|
4
|
+
export const TOOLS = [
|
|
5
|
+
// ========== Store Tools (4) ==========
|
|
6
|
+
{
|
|
7
|
+
name: 'gemini_create_store',
|
|
8
|
+
description: 'Create a new Gemini File Search store for RAG documents. Returns the created store resource. Use this to create a knowledge base before uploading documents.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
display_name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Display name for the store (max 512 characters)',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ['display_name'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'gemini_list_stores',
|
|
22
|
+
description: 'List all Gemini File Search stores. Returns store names, display names, and timestamps. Use to see available knowledge bases.',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
page_size: {
|
|
27
|
+
type: 'number',
|
|
28
|
+
description: 'Number of stores to return per page (default 10, max 20)',
|
|
29
|
+
},
|
|
30
|
+
page_token: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Token for next page from previous response',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'gemini_get_store',
|
|
39
|
+
description: 'Get details of a specific Gemini File Search store by its resource name.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
store_name: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Store resource name, e.g. "fileSearchStores/abc123"',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['store_name'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'gemini_delete_store',
|
|
53
|
+
description: 'Delete a Gemini File Search store. Use force=true to also delete all documents inside it.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
store_name: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Store resource name, e.g. "fileSearchStores/abc123"',
|
|
60
|
+
},
|
|
61
|
+
force: {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
description: 'If true, cascade delete all documents in the store',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
required: ['store_name'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
// ========== Upload & Import Tools (2) ==========
|
|
70
|
+
{
|
|
71
|
+
name: 'gemini_upload_to_store',
|
|
72
|
+
description: 'Upload content directly to a Gemini File Search store. Accepts text content or base64-encoded binary. For large files, use gemini_import_file_to_store instead. Returns an operation to track upload progress.',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
store_name: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Store resource name, e.g. "fileSearchStores/abc123"',
|
|
79
|
+
},
|
|
80
|
+
mime_type: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description: 'MIME type of the content, e.g. "text/plain", "application/pdf", "text/markdown"',
|
|
83
|
+
},
|
|
84
|
+
content: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'The content to upload. Plain text by default, or base64-encoded if content_encoding is "base64"',
|
|
87
|
+
},
|
|
88
|
+
display_name: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'Display name for the document (optional)',
|
|
91
|
+
},
|
|
92
|
+
content_encoding: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
enum: ['text', 'base64'],
|
|
95
|
+
description: 'How the content is encoded: "text" (default) or "base64" for binary files',
|
|
96
|
+
},
|
|
97
|
+
custom_metadata: {
|
|
98
|
+
type: 'array',
|
|
99
|
+
items: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
key: { type: 'string' },
|
|
103
|
+
stringValue: { type: 'string' },
|
|
104
|
+
numericValue: { type: 'number' },
|
|
105
|
+
},
|
|
106
|
+
required: ['key'],
|
|
107
|
+
},
|
|
108
|
+
description: 'Custom metadata key-value pairs for filtering (max 20)',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
required: ['store_name', 'mime_type', 'content'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'gemini_import_file_to_store',
|
|
116
|
+
description: 'Import a file from the Gemini Files API into a File Search store. Use this for large files that were uploaded separately via the Files API. Returns an operation to track import progress.',
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
store_name: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: 'Store resource name, e.g. "fileSearchStores/abc123"',
|
|
123
|
+
},
|
|
124
|
+
file_name: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'Gemini file resource name, e.g. "files/abc-123"',
|
|
127
|
+
},
|
|
128
|
+
custom_metadata: {
|
|
129
|
+
type: 'array',
|
|
130
|
+
items: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
key: { type: 'string' },
|
|
134
|
+
stringValue: { type: 'string' },
|
|
135
|
+
numericValue: { type: 'number' },
|
|
136
|
+
},
|
|
137
|
+
required: ['key'],
|
|
138
|
+
},
|
|
139
|
+
description: 'Custom metadata key-value pairs for filtering (max 20)',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
required: ['store_name', 'file_name'],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
// ========== Operation Tools (2) ==========
|
|
146
|
+
{
|
|
147
|
+
name: 'gemini_get_operation',
|
|
148
|
+
description: 'Check the status of a store operation (create, delete, import). Returns whether the operation is done and any error details.',
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
operation_name: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'Operation resource name, e.g. "fileSearchStores/abc123/operations/op456"',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
required: ['operation_name'],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'gemini_get_upload_operation',
|
|
162
|
+
description: 'Check the status of a file upload operation. Returns whether the upload is done and any error details.',
|
|
163
|
+
inputSchema: {
|
|
164
|
+
type: 'object',
|
|
165
|
+
properties: {
|
|
166
|
+
operation_name: {
|
|
167
|
+
type: 'string',
|
|
168
|
+
description: 'Upload operation resource name, e.g. "fileSearchStores/abc123/upload/operations/op789"',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
required: ['operation_name'],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
// ========== Document Tools (3) ==========
|
|
175
|
+
{
|
|
176
|
+
name: 'gemini_list_documents',
|
|
177
|
+
description: 'List documents in a Gemini File Search store. Returns document names, display names, state, size, and MIME types.',
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: 'object',
|
|
180
|
+
properties: {
|
|
181
|
+
store_name: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
description: 'Store resource name, e.g. "fileSearchStores/abc123"',
|
|
184
|
+
},
|
|
185
|
+
page_size: {
|
|
186
|
+
type: 'number',
|
|
187
|
+
description: 'Number of documents to return per page (default 10, max 20)',
|
|
188
|
+
},
|
|
189
|
+
page_token: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'Token for next page from previous response',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
required: ['store_name'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'gemini_get_document',
|
|
199
|
+
description: 'Get details of a specific document in a File Search store, including state, size, and metadata.',
|
|
200
|
+
inputSchema: {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
document_name: {
|
|
204
|
+
type: 'string',
|
|
205
|
+
description: 'Document resource name, e.g. "fileSearchStores/abc123/documents/doc456"',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
required: ['document_name'],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'gemini_delete_document',
|
|
213
|
+
description: 'Delete a document from a File Search store. Use force=true to also delete associated chunks.',
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
properties: {
|
|
217
|
+
document_name: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
description: 'Document resource name, e.g. "fileSearchStores/abc123/documents/doc456"',
|
|
220
|
+
},
|
|
221
|
+
force: {
|
|
222
|
+
type: 'boolean',
|
|
223
|
+
description: 'If true, also delete associated chunks',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
required: ['document_name'],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
// ========== RAG Query Tool (1) ==========
|
|
230
|
+
{
|
|
231
|
+
name: 'gemini_rag_query',
|
|
232
|
+
description: 'Query your documents using Gemini RAG. Sends a natural language query grounded in your File Search stores. Returns AI-generated answer with source citations from your documents.',
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
query: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
description: 'Natural language query to search your documents',
|
|
239
|
+
},
|
|
240
|
+
store_names: {
|
|
241
|
+
type: 'array',
|
|
242
|
+
items: { type: 'string' },
|
|
243
|
+
description: 'Array of store resource names to search, e.g. ["fileSearchStores/abc123"]',
|
|
244
|
+
},
|
|
245
|
+
model: {
|
|
246
|
+
type: 'string',
|
|
247
|
+
description: 'Gemini model to use (default: "gemini-2.5-flash-lite"). Options: gemini-2.5-flash-lite, gemini-2.5-flash, gemini-2.5-pro',
|
|
248
|
+
},
|
|
249
|
+
metadata_filter: {
|
|
250
|
+
type: 'string',
|
|
251
|
+
description: 'Optional metadata filter expression (Google AIP-160 syntax)',
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
required: ['query', 'store_names'],
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,wCAAwC;IACxC;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,8JAA8J;QAChK,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iDA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ACvF;aACF;YACD,QAAQ,EAAE,CAAC,eAAe,CAAC;SAC5B;KACF;IACD;QACE,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EACT,8FAA8F;QAChG,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,aAAa,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yEAAyE;iBACvF;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,wCAAwC;iBACtD;aACF;YACD,QAAQ,EAAE,CAAC,eAAe,CAAC;SAC5B;KACF;IAED,2CAA2C;IAC3C;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,mLAAmL;QACrL,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iDAAiD;iBAC/D;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,2EAA2E;iBACzF;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0HAA0H;iBACxI;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6DAA6D;iBAC3E;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;SACnC;KACF;CACF,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini RAG File Search - Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
export interface GeminiRagConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FileSearchStore {
|
|
8
|
+
name: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
createTime: string;
|
|
11
|
+
updateTime: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FileSearchStoreList {
|
|
14
|
+
fileSearchStores: FileSearchStore[];
|
|
15
|
+
nextPageToken?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FileSearchDocument {
|
|
18
|
+
name: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
createTime: string;
|
|
21
|
+
updateTime: string;
|
|
22
|
+
state: 'PENDING' | 'ACTIVE' | 'FAILED';
|
|
23
|
+
sizeBytes?: string;
|
|
24
|
+
mimeType?: string;
|
|
25
|
+
customMetadata?: CustomMetadata[];
|
|
26
|
+
}
|
|
27
|
+
export interface FileSearchDocumentList {
|
|
28
|
+
documents: FileSearchDocument[];
|
|
29
|
+
nextPageToken?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface StringList {
|
|
32
|
+
values: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface CustomMetadata {
|
|
35
|
+
key: string;
|
|
36
|
+
stringValue?: string;
|
|
37
|
+
numericValue?: number;
|
|
38
|
+
stringListValue?: StringList;
|
|
39
|
+
}
|
|
40
|
+
export interface ChunkingConfig {
|
|
41
|
+
chunkSize?: number;
|
|
42
|
+
chunkOverlap?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface GeminiOperation {
|
|
45
|
+
name: string;
|
|
46
|
+
done: boolean;
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
48
|
+
error?: {
|
|
49
|
+
code: number;
|
|
50
|
+
message: string;
|
|
51
|
+
details?: unknown[];
|
|
52
|
+
};
|
|
53
|
+
response?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface GenerateContentResponse {
|
|
56
|
+
candidates: Array<{
|
|
57
|
+
content: {
|
|
58
|
+
parts: Array<{
|
|
59
|
+
text?: string;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
groundingMetadata?: {
|
|
63
|
+
groundingChunks?: Array<{
|
|
64
|
+
retrievedContext?: {
|
|
65
|
+
uri: string;
|
|
66
|
+
title: string;
|
|
67
|
+
text: string;
|
|
68
|
+
};
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,KAAK,CAAC;QAChB,OAAO,EAAE;YACP,KAAK,EAAE,KAAK,CAAC;gBACX,IAAI,CAAC,EAAE,MAAM,CAAC;aACf,CAAC,CAAC;SACJ,CAAC;QACF,iBAAiB,CAAC,EAAE;YAClB,eAAe,CAAC,EAAE,KAAK,CAAC;gBACtB,gBAAgB,CAAC,EAAE;oBACjB,GAAG,EAAE,MAAM,CAAC;oBACZ,KAAK,EAAE,MAAM,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC;iBACd,CAAC;aACH,CAAC,CAAC;SACJ,CAAC;KACH,CAAC,CAAC;CACJ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Worker entry point for Gemini RAG MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Deploys the MCP server on Cloudflare Workers using Web Standard APIs.
|
|
5
|
+
* Each request creates a fresh transport+server (stateless mode).
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: {
|
|
8
|
+
fetch(request: Request): Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;mBA+BoB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADlD,wBAyDE"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Worker entry point for Gemini RAG MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Deploys the MCP server on Cloudflare Workers using Web Standard APIs.
|
|
5
|
+
* Each request creates a fresh transport+server (stateless mode).
|
|
6
|
+
*/
|
|
7
|
+
import { WebStandardStreamableHTTPServerTransport, } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
8
|
+
import { createServer } from './server.js';
|
|
9
|
+
import { TOOLS } from './tools.js';
|
|
10
|
+
function corsHeaders() {
|
|
11
|
+
return {
|
|
12
|
+
'Access-Control-Allow-Origin': '*',
|
|
13
|
+
'Access-Control-Allow-Methods': 'GET, POST, DELETE, OPTIONS',
|
|
14
|
+
'Access-Control-Allow-Headers': 'Content-Type, mcp-session-id, Accept, mcp-protocol-version',
|
|
15
|
+
'Access-Control-Expose-Headers': 'mcp-session-id',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function addCors(response) {
|
|
19
|
+
const headers = new Headers(response.headers);
|
|
20
|
+
for (const [key, value] of Object.entries(corsHeaders())) {
|
|
21
|
+
headers.set(key, value);
|
|
22
|
+
}
|
|
23
|
+
return new Response(response.body, {
|
|
24
|
+
status: response.status,
|
|
25
|
+
statusText: response.statusText,
|
|
26
|
+
headers,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export default {
|
|
30
|
+
async fetch(request) {
|
|
31
|
+
const url = new URL(request.url);
|
|
32
|
+
// CORS preflight
|
|
33
|
+
if (request.method === 'OPTIONS') {
|
|
34
|
+
return new Response(null, { status: 204, headers: corsHeaders() });
|
|
35
|
+
}
|
|
36
|
+
// Health check
|
|
37
|
+
if (url.pathname === '/' && request.method === 'GET') {
|
|
38
|
+
return addCors(Response.json({
|
|
39
|
+
name: 'gemini-rag-mcp',
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
status: 'ok',
|
|
42
|
+
tools: TOOLS.length,
|
|
43
|
+
transport: 'streamable-http',
|
|
44
|
+
endpoints: { mcp: '/mcp' },
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
// Only /mcp endpoint
|
|
48
|
+
if (url.pathname !== '/mcp') {
|
|
49
|
+
return addCors(new Response('Not Found', { status: 404 }));
|
|
50
|
+
}
|
|
51
|
+
// Only POST supported in stateless mode
|
|
52
|
+
if (request.method !== 'POST') {
|
|
53
|
+
return addCors(Response.json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed. Use POST.' }, id: null }, { status: 405 }));
|
|
54
|
+
}
|
|
55
|
+
// Read Gemini API key from query params (Smithery gateway sends these)
|
|
56
|
+
const apiKey = url.searchParams.get('GEMINI_API_KEY');
|
|
57
|
+
const config = apiKey ? { apiKey } : undefined;
|
|
58
|
+
try {
|
|
59
|
+
// Stateless: new transport + server per request
|
|
60
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
61
|
+
sessionIdGenerator: undefined,
|
|
62
|
+
enableJsonResponse: true,
|
|
63
|
+
});
|
|
64
|
+
const server = createServer(config);
|
|
65
|
+
await server.connect(transport);
|
|
66
|
+
const response = await transport.handleRequest(request);
|
|
67
|
+
return addCors(response);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return addCors(Response.json({ jsonrpc: '2.0', error: { code: -32603, message: error.message || 'Internal server error' }, id: null }, { status: 500 }));
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
//#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AAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACpC,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAEhC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAC1B,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,uBAAuB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EACxG,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@node2flow/gemini-file-search-rag-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Gemini RAG — manage File Search stores, upload documents, and query with AI-powered retrieval-augmented generation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gemini-file-search-rag-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./src/index.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"start": "node dist/index.js",
|
|
19
|
+
"dev": "tsx src/index.ts",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"deploy": "wrangler deploy"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"gemini",
|
|
25
|
+
"rag",
|
|
26
|
+
"mcp",
|
|
27
|
+
"model-context-protocol",
|
|
28
|
+
"file-search",
|
|
29
|
+
"ai",
|
|
30
|
+
"claude",
|
|
31
|
+
"cursor",
|
|
32
|
+
"google",
|
|
33
|
+
"retrieval-augmented-generation"
|
|
34
|
+
],
|
|
35
|
+
"author": "Node2Flow",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/node2flow-th/gemini-files-search-rag-mcp-community.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/node2flow-th/gemini-files-search-rag-mcp-community",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.26.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"tsx": "^4.0.0",
|
|
48
|
+
"typescript": "^5.7.2",
|
|
49
|
+
"wrangler": "^4.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|