mcp-server-gemini 1.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/CHANGELOG.md +155 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/dist/config/constants.js +71 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/models.js +121 -0
- package/dist/config/models.js.map +1 -0
- package/dist/enhanced-stdio-server.js +1164 -0
- package/dist/enhanced-stdio-server.js.map +1 -0
- package/dist/i18n.js +109 -0
- package/dist/i18n.js.map +1 -0
- package/dist/server.js +251 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/analyze-codebase.js +373 -0
- package/dist/tools/analyze-codebase.js.map +1 -0
- package/dist/tools/analyze-content.js +295 -0
- package/dist/tools/analyze-content.js.map +1 -0
- package/dist/tools/brainstorm.js +237 -0
- package/dist/tools/brainstorm.js.map +1 -0
- package/dist/tools/definitions.js +375 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/fix-ui.js +262 -0
- package/dist/tools/fix-ui.js.map +1 -0
- package/dist/tools/generate-ui.js +311 -0
- package/dist/tools/generate-ui.js.map +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-models.js +30 -0
- package/dist/tools/list-models.js.map +1 -0
- package/dist/tools/multimodal-query.js +83 -0
- package/dist/tools/multimodal-query.js.map +1 -0
- package/dist/tools/search.js +94 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/error-handler.js +69 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/file-reader.js +470 -0
- package/dist/utils/file-reader.js.map +1 -0
- package/dist/utils/gemini-client.js +184 -0
- package/dist/utils/gemini-client.js.map +1 -0
- package/dist/utils/security.js +370 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/validators.js +150 -0
- package/dist/utils/validators.js.map +1 -0
- package/dist/windows-utils.js +175 -0
- package/dist/windows-utils.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool 2: gemini_multimodal_query
|
|
3
|
+
* Query using images + text for multimodal understanding
|
|
4
|
+
* Priority: P0 - Core functionality
|
|
5
|
+
*/
|
|
6
|
+
import { validateRequired, validateString, validateArray, validateOutputFormat } from '../utils/validators.js';
|
|
7
|
+
import { handleAPIError, logError } from '../utils/error-handler.js';
|
|
8
|
+
// System prompt for multimodal query
|
|
9
|
+
const MULTIMODAL_QUERY_SYSTEM_PROMPT = `You are a visual understanding expert with deep knowledge of:
|
|
10
|
+
- UI/UX design patterns and principles
|
|
11
|
+
- Frontend development (HTML/CSS/JavaScript)
|
|
12
|
+
- Architecture diagrams and technical documentation
|
|
13
|
+
- Design systems and component libraries
|
|
14
|
+
|
|
15
|
+
When analyzing images:
|
|
16
|
+
1. Identify all key elements and their purposes
|
|
17
|
+
2. Understand spatial relationships and layouts
|
|
18
|
+
3. Recognize design patterns and conventions
|
|
19
|
+
4. Detect colors, typography, spacing with precision
|
|
20
|
+
5. Infer interactive states (hover, active, disabled)
|
|
21
|
+
|
|
22
|
+
When asked to convert designs to code:
|
|
23
|
+
- Provide complete, production-ready implementation
|
|
24
|
+
- Match the design pixel-perfectly
|
|
25
|
+
- Include all visible and implied interactions
|
|
26
|
+
|
|
27
|
+
When asked questions about designs:
|
|
28
|
+
- Be specific and detailed
|
|
29
|
+
- Reference exact colors (hex codes)
|
|
30
|
+
- Mention spacing values when relevant
|
|
31
|
+
- Suggest improvements if asked
|
|
32
|
+
|
|
33
|
+
Output format:
|
|
34
|
+
- Adapt to the requested format (text/code/json)
|
|
35
|
+
- Be concise but comprehensive
|
|
36
|
+
- Use professional terminology`;
|
|
37
|
+
/**
|
|
38
|
+
* Handle gemini_multimodal_query tool call
|
|
39
|
+
*/
|
|
40
|
+
export async function handleMultimodalQuery(params, client) {
|
|
41
|
+
try {
|
|
42
|
+
// Validate required parameters
|
|
43
|
+
validateRequired(params.prompt, 'prompt');
|
|
44
|
+
validateString(params.prompt, 'prompt', 5);
|
|
45
|
+
validateRequired(params.images, 'images');
|
|
46
|
+
validateArray(params.images, 'images', 1);
|
|
47
|
+
// Validate optional parameters
|
|
48
|
+
const outputFormat = params.outputFormat || 'text';
|
|
49
|
+
if (params.outputFormat) {
|
|
50
|
+
validateOutputFormat(params.outputFormat);
|
|
51
|
+
}
|
|
52
|
+
// Build the prompt
|
|
53
|
+
let fullPrompt = params.prompt;
|
|
54
|
+
if (params.context) {
|
|
55
|
+
fullPrompt = `Context: ${params.context}\n\nQuestion: ${params.prompt}`;
|
|
56
|
+
}
|
|
57
|
+
if (outputFormat === 'json') {
|
|
58
|
+
fullPrompt += `\n\nPlease provide your response in valid JSON format.`;
|
|
59
|
+
}
|
|
60
|
+
else if (outputFormat === 'code') {
|
|
61
|
+
fullPrompt += `\n\nPlease provide your response as code only, no explanations.`;
|
|
62
|
+
}
|
|
63
|
+
// Call Gemini API with multimodal input
|
|
64
|
+
const response = await client.generateMultimodal(fullPrompt, params.images, {
|
|
65
|
+
systemInstruction: MULTIMODAL_QUERY_SYSTEM_PROMPT,
|
|
66
|
+
temperature: 0.7,
|
|
67
|
+
maxTokens: 4096
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
response,
|
|
71
|
+
format: outputFormat,
|
|
72
|
+
metadata: {
|
|
73
|
+
imageCount: params.images.length,
|
|
74
|
+
modelUsed: client.getModel()
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
logError('multimodalQuery', error);
|
|
80
|
+
throw handleAPIError(error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=multimodal-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multimodal-query.js","sourceRoot":"","sources":["../../src/tools/multimodal-query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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AM,CAAC,kBAAkB,CAC9C,UAAU,EACV,MAAM,CAAC,MAAM,EACb;YACE,iBAAiB,EAAE,8BAA8B;YACjD,WAAW,EAAE,GAAG;YAChB,SAAS,EAAE,IAAI;SAChB,CACF,CAAC;QAEF,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,YAAY;YACpB,QAAQ,EAAE;gBACR,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAChC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE;aAC7B;SACF,CAAC;IAEJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool: gemini_search
|
|
3
|
+
* Web search using Gemini's built-in Google Search grounding
|
|
4
|
+
*/
|
|
5
|
+
import { GoogleGenAI } from '@google/genai';
|
|
6
|
+
import { validateRequired, validateString } from '../utils/validators.js';
|
|
7
|
+
import { handleAPIError, logError } from '../utils/error-handler.js';
|
|
8
|
+
// Search system prompt
|
|
9
|
+
const SEARCH_SYSTEM_PROMPT = `You are a helpful research assistant with access to Google Search.
|
|
10
|
+
When answering questions:
|
|
11
|
+
1. Use the search results to provide accurate, up-to-date information
|
|
12
|
+
2. Cite sources when possible
|
|
13
|
+
3. Be clear about what information comes from search results
|
|
14
|
+
4. If search results are insufficient, acknowledge limitations
|
|
15
|
+
5. Synthesize information from multiple sources when relevant`;
|
|
16
|
+
/**
|
|
17
|
+
* Handle gemini_search tool invocation
|
|
18
|
+
*/
|
|
19
|
+
export async function handleSearch(params, apiKey) {
|
|
20
|
+
try {
|
|
21
|
+
// Parameter validation
|
|
22
|
+
validateRequired(params.query, 'query');
|
|
23
|
+
validateString(params.query, 'query', 2);
|
|
24
|
+
if (params.context) {
|
|
25
|
+
validateString(params.context, 'context', 2);
|
|
26
|
+
}
|
|
27
|
+
const thinkingLevel = params.thinkingLevel || 'high';
|
|
28
|
+
const outputFormat = params.outputFormat || 'text';
|
|
29
|
+
// Create AI client
|
|
30
|
+
const ai = new GoogleGenAI({ apiKey });
|
|
31
|
+
// Configure tools with Google Search
|
|
32
|
+
const tools = [{ googleSearch: {} }];
|
|
33
|
+
const config = {
|
|
34
|
+
tools,
|
|
35
|
+
thinkingConfig: { thinkingLevel },
|
|
36
|
+
};
|
|
37
|
+
// Add JSON output configuration if requested
|
|
38
|
+
if (outputFormat === 'json') {
|
|
39
|
+
config.responseMimeType = 'application/json';
|
|
40
|
+
}
|
|
41
|
+
// Build prompt
|
|
42
|
+
let prompt = params.query;
|
|
43
|
+
if (params.context) {
|
|
44
|
+
prompt = `Context: ${params.context}\n\nQuestion: ${params.query}`;
|
|
45
|
+
}
|
|
46
|
+
const model = 'gemini-3-pro-preview';
|
|
47
|
+
const contents = [
|
|
48
|
+
{
|
|
49
|
+
role: 'user',
|
|
50
|
+
parts: [{ text: prompt }],
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
// Add system instruction to config
|
|
54
|
+
config.systemInstruction = SEARCH_SYSTEM_PROMPT;
|
|
55
|
+
// Call Gemini API with search grounding
|
|
56
|
+
const response = await ai.models.generateContent({
|
|
57
|
+
model,
|
|
58
|
+
config,
|
|
59
|
+
contents,
|
|
60
|
+
});
|
|
61
|
+
// Extract response text
|
|
62
|
+
const responseText = response.text || '';
|
|
63
|
+
// Extract grounding metadata if available
|
|
64
|
+
let groundingMetadata;
|
|
65
|
+
const candidate = response.candidates?.[0];
|
|
66
|
+
if (candidate?.groundingMetadata) {
|
|
67
|
+
const metadata = candidate.groundingMetadata;
|
|
68
|
+
groundingMetadata = {
|
|
69
|
+
searchQueries: metadata.webSearchQueries,
|
|
70
|
+
webSearchSources: metadata.groundingSupports?.map((support) => ({
|
|
71
|
+
title: support.segment?.text,
|
|
72
|
+
uri: support.groundingChunkIndices?.[0] !== undefined
|
|
73
|
+
? metadata.groundingChunks?.[support.groundingChunkIndices[0]]?.web?.uri
|
|
74
|
+
: undefined,
|
|
75
|
+
})),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
query: params.query,
|
|
80
|
+
response: responseText,
|
|
81
|
+
groundingMetadata,
|
|
82
|
+
metadata: {
|
|
83
|
+
modelUsed: model,
|
|
84
|
+
thinkingLevel,
|
|
85
|
+
outputFormat,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
logError('search', error);
|
|
91
|
+
throw handleAPIError(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErE,uBAAuB;AACvB,MAAM,oBAAoB,GAAG;;;;;;8DAMiC,CAAC;AA4B/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoB,EACpB,MAAc;IAEd,IAAI,CAAC;QACH,uBAAuB;QACvB,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,CAAC,aAA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S,EAAE,iBAAiB,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,SAAS,CAAC,iBAAwB,CAAC;YACpD,iBAAiB,GAAG;gBAClB,aAAa,EAAE,QAAQ,CAAC,gBAAgB;gBACxC,gBAAgB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,CAAC;oBACnE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI;oBAC5B,GAAG,EAAE,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;wBACnD,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG;wBACxE,CAAC,CAAC,SAAS;iBACd,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,YAAY;YACtB,iBAAiB;YACjB,QAAQ,EAAE;gBACR,SAAS,EAAE,KAAK;gBAChB,aAAa;gBACb,YAAY;aACb;SACF,CAAC;IAEJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1B,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities
|
|
3
|
+
*/
|
|
4
|
+
import { ERROR_CODES } from '../config/constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create MCP error object
|
|
7
|
+
*/
|
|
8
|
+
export function createMCPError(code, message, data) {
|
|
9
|
+
return { code, message, data };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Handle API errors
|
|
13
|
+
*/
|
|
14
|
+
export function handleAPIError(error) {
|
|
15
|
+
// API Key error
|
|
16
|
+
if (error.message?.includes('API key') || error.message?.includes('Invalid key')) {
|
|
17
|
+
return createMCPError(ERROR_CODES.API_ERROR, 'Invalid API key. Please check your GEMINI_API_KEY environment variable.', { originalError: error.message });
|
|
18
|
+
}
|
|
19
|
+
// Quota error
|
|
20
|
+
if (error.message?.includes('quota') || error.message?.includes('rate limit')) {
|
|
21
|
+
return createMCPError(ERROR_CODES.RATE_LIMIT, 'API quota exceeded or rate limit reached. Please try again later.', { originalError: error.message });
|
|
22
|
+
}
|
|
23
|
+
// Timeout error
|
|
24
|
+
if (error.message?.includes('timeout')) {
|
|
25
|
+
return createMCPError(ERROR_CODES.TIMEOUT, 'Request timeout. The operation took too long to complete.', { originalError: error.message });
|
|
26
|
+
}
|
|
27
|
+
// Model not supported
|
|
28
|
+
if (error.message?.includes('model') || error.message?.includes('not found')) {
|
|
29
|
+
return createMCPError(ERROR_CODES.MODEL_NOT_SUPPORTED, 'The specified model is not supported or not available.', { originalError: error.message });
|
|
30
|
+
}
|
|
31
|
+
// Generic API error
|
|
32
|
+
return createMCPError(ERROR_CODES.API_ERROR, error.message || 'An error occurred while calling the Gemini API.', { originalError: error.message });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Handle parameter validation errors
|
|
36
|
+
*/
|
|
37
|
+
export function handleValidationError(message, details) {
|
|
38
|
+
return createMCPError(ERROR_CODES.INVALID_PARAMS, message, details);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Handle internal errors
|
|
42
|
+
*/
|
|
43
|
+
export function handleInternalError(error) {
|
|
44
|
+
return createMCPError(ERROR_CODES.INTERNAL_ERROR, 'Internal server error', { originalError: error.message });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sanitize error message (prevent sensitive information leakage)
|
|
48
|
+
*/
|
|
49
|
+
export function sanitizeErrorMessage(error) {
|
|
50
|
+
if (typeof error === 'string') {
|
|
51
|
+
return error.replace(/apiKey\s*=\s*[^\s]+/gi, 'apiKey=***');
|
|
52
|
+
}
|
|
53
|
+
if (error.message) {
|
|
54
|
+
return error.message.replace(/apiKey\s*=\s*[^\s]+/gi, 'apiKey=***');
|
|
55
|
+
}
|
|
56
|
+
return 'Unknown error';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Log error (for debugging)
|
|
60
|
+
*/
|
|
61
|
+
export function logError(context, error) {
|
|
62
|
+
const timestamp = new Date().toISOString();
|
|
63
|
+
const sanitized = sanitizeErrorMessage(error);
|
|
64
|
+
console.error(`[${timestamp}] [${context}] Error:`, sanitized);
|
|
65
|
+
if (error.stack) {
|
|
66
|
+
console.error('Stack trace:', error.stack);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,OAAe,EAAE,IAAU;IACtE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAU;IACvC,gBAAgB;IAChB,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACjF,OAAO,cAAc,CACnB,WAAW,CAAC,SAAS,EACrB,yEAAyE,EACzE,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,CACjC,CAAC;IACJ,CAAC;IAED,cAAc;IACd,I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