@react-native-nitro-device-info/mcp-server 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/README.md +220 -0
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +153 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +375 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/api-parser.d.ts +23 -0
- package/dist/indexer/api-parser.d.ts.map +1 -0
- package/dist/indexer/api-parser.js +404 -0
- package/dist/indexer/api-parser.js.map +1 -0
- package/dist/indexer/doc-parser.d.ts +38 -0
- package/dist/indexer/doc-parser.d.ts.map +1 -0
- package/dist/indexer/doc-parser.js +359 -0
- package/dist/indexer/doc-parser.js.map +1 -0
- package/dist/indexer/index.d.ts +54 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +151 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/indexer/search.d.ts +36 -0
- package/dist/indexer/search.d.ts.map +1 -0
- package/dist/indexer/search.js +511 -0
- package/dist/indexer/search.js.map +1 -0
- package/dist/tools/get-api.d.ts +26 -0
- package/dist/tools/get-api.d.ts.map +1 -0
- package/dist/tools/get-api.js +229 -0
- package/dist/tools/get-api.js.map +1 -0
- package/dist/tools/list-apis.d.ts +32 -0
- package/dist/tools/list-apis.d.ts.map +1 -0
- package/dist/tools/list-apis.js +210 -0
- package/dist/tools/list-apis.js.map +1 -0
- package/dist/tools/search-docs.d.ts +32 -0
- package/dist/tools/search-docs.d.ts.map +1 -0
- package/dist/tools/search-docs.js +148 -0
- package/dist/tools/search-docs.js.map +1 -0
- package/dist/types/index.d.ts +166 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* get_api MCP Tool
|
|
4
|
+
*
|
|
5
|
+
* Retrieve detailed information about a specific API method or property.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getApiInputSchema = void 0;
|
|
9
|
+
exports.executeGetApi = executeGetApi;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const search_js_1 = require("../indexer/search.js");
|
|
12
|
+
/**
|
|
13
|
+
* Input schema for get_api tool
|
|
14
|
+
*/
|
|
15
|
+
exports.getApiInputSchema = zod_1.z.object({
|
|
16
|
+
name: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1, 'API name cannot be empty')
|
|
19
|
+
.max(100, 'API name exceeds maximum length')
|
|
20
|
+
.describe("API method or property name (e.g., 'getBatteryLevel', 'deviceId'). Case-insensitive lookup with exact-match boost."),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Format platform support table
|
|
24
|
+
*/
|
|
25
|
+
function formatPlatformSupport(platform) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
lines.push('| Platform | Support |');
|
|
28
|
+
lines.push('|----------|---------|');
|
|
29
|
+
switch (platform.type) {
|
|
30
|
+
case 'both':
|
|
31
|
+
lines.push('| iOS | ✅ Full support |');
|
|
32
|
+
lines.push('| Android | ✅ Full support |');
|
|
33
|
+
break;
|
|
34
|
+
case 'ios':
|
|
35
|
+
lines.push(`| iOS | ✅ ${platform.minVersion ? `iOS ${platform.minVersion}+` : 'Full support'} |`);
|
|
36
|
+
lines.push('| Android | ✅ Full support |');
|
|
37
|
+
break;
|
|
38
|
+
case 'android':
|
|
39
|
+
lines.push('| iOS | ✅ Full support |');
|
|
40
|
+
lines.push(`| Android | ✅ ${platform.minApiLevel ? `API ${platform.minApiLevel}+` : 'Full support'} |`);
|
|
41
|
+
break;
|
|
42
|
+
case 'ios-only':
|
|
43
|
+
lines.push(`| iOS | ✅ ${platform.minVersion ? `iOS ${platform.minVersion}+` : 'Full support'} |`);
|
|
44
|
+
lines.push('| Android | ❌ Not supported |');
|
|
45
|
+
break;
|
|
46
|
+
case 'android-only':
|
|
47
|
+
lines.push('| iOS | ❌ Not supported |');
|
|
48
|
+
lines.push(`| Android | ✅ ${platform.minApiLevel ? `API ${platform.minApiLevel}+` : 'Full support'} |`);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return lines.join('\n');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format parameters table
|
|
55
|
+
*/
|
|
56
|
+
function formatParameters(api) {
|
|
57
|
+
if (api.parameters.length === 0) {
|
|
58
|
+
return '*No parameters.*';
|
|
59
|
+
}
|
|
60
|
+
const lines = [];
|
|
61
|
+
lines.push('| Name | Type | Required | Description |');
|
|
62
|
+
lines.push('|------|------|----------|-------------|');
|
|
63
|
+
for (const param of api.parameters) {
|
|
64
|
+
const required = param.optional ? 'No' : 'Yes';
|
|
65
|
+
lines.push(`| ${param.name} | \`${param.type}\` | ${required} | ${param.description || '-'} |`);
|
|
66
|
+
}
|
|
67
|
+
return lines.join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Format related APIs section
|
|
71
|
+
*/
|
|
72
|
+
function formatRelatedApis(relatedApis) {
|
|
73
|
+
if (relatedApis.length === 0) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
const lines = [];
|
|
77
|
+
lines.push('## Related APIs');
|
|
78
|
+
lines.push('');
|
|
79
|
+
for (const api of relatedApis) {
|
|
80
|
+
lines.push(`- \`${api}()\``);
|
|
81
|
+
}
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Format examples section
|
|
86
|
+
*/
|
|
87
|
+
function formatExamples(examples) {
|
|
88
|
+
if (examples.length === 0) {
|
|
89
|
+
return '*No examples documented.*';
|
|
90
|
+
}
|
|
91
|
+
const lines = [];
|
|
92
|
+
for (const example of examples) {
|
|
93
|
+
// Check if example already has code fence
|
|
94
|
+
if (example.includes('```')) {
|
|
95
|
+
lines.push(example);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
lines.push('```typescript');
|
|
99
|
+
lines.push(example);
|
|
100
|
+
lines.push('```');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return lines.join('\n');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Format complete API documentation
|
|
107
|
+
*/
|
|
108
|
+
function formatApiDocumentation(api) {
|
|
109
|
+
const lines = [];
|
|
110
|
+
// Title
|
|
111
|
+
lines.push(`# ${api.name}`);
|
|
112
|
+
lines.push('');
|
|
113
|
+
// Description
|
|
114
|
+
lines.push(api.description);
|
|
115
|
+
lines.push('');
|
|
116
|
+
// Signature
|
|
117
|
+
lines.push('## Signature');
|
|
118
|
+
lines.push('');
|
|
119
|
+
lines.push('```typescript');
|
|
120
|
+
lines.push(api.signature);
|
|
121
|
+
lines.push('```');
|
|
122
|
+
lines.push('');
|
|
123
|
+
// Parameters
|
|
124
|
+
lines.push('## Parameters');
|
|
125
|
+
lines.push('');
|
|
126
|
+
lines.push(formatParameters(api));
|
|
127
|
+
lines.push('');
|
|
128
|
+
// Returns
|
|
129
|
+
lines.push('## Returns');
|
|
130
|
+
lines.push('');
|
|
131
|
+
lines.push(`\`${api.returnType}\``);
|
|
132
|
+
lines.push('');
|
|
133
|
+
if (api.isAsync) {
|
|
134
|
+
lines.push('*This is an async method that returns a Promise.*');
|
|
135
|
+
lines.push('');
|
|
136
|
+
}
|
|
137
|
+
// Platform Support
|
|
138
|
+
lines.push('## Platform Support');
|
|
139
|
+
lines.push('');
|
|
140
|
+
lines.push(formatPlatformSupport(api.platform));
|
|
141
|
+
lines.push('');
|
|
142
|
+
// Example
|
|
143
|
+
lines.push('## Example');
|
|
144
|
+
lines.push('');
|
|
145
|
+
lines.push(formatExamples(api.examples));
|
|
146
|
+
lines.push('');
|
|
147
|
+
// Import suggestion
|
|
148
|
+
lines.push('## Import');
|
|
149
|
+
lines.push('');
|
|
150
|
+
lines.push('```typescript');
|
|
151
|
+
lines.push("import { NitroModules } from 'react-native-nitro-modules';");
|
|
152
|
+
lines.push("import type { DeviceInfo } from 'react-native-nitro-device-info';");
|
|
153
|
+
lines.push('');
|
|
154
|
+
lines.push("const deviceInfo = NitroModules.createHybridObject<DeviceInfo>('DeviceInfo');");
|
|
155
|
+
lines.push('');
|
|
156
|
+
if (api.kind === 'method') {
|
|
157
|
+
if (api.isAsync) {
|
|
158
|
+
lines.push(`const result = await deviceInfo.${api.name}(${api.parameters.map(p => p.name).join(', ')});`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
lines.push(`const result = deviceInfo.${api.name}(${api.parameters.map(p => p.name).join(', ')});`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
lines.push(`const result = deviceInfo.${api.name};`);
|
|
166
|
+
}
|
|
167
|
+
lines.push('```');
|
|
168
|
+
lines.push('');
|
|
169
|
+
// Related APIs
|
|
170
|
+
const relatedSection = formatRelatedApis(api.relatedApis);
|
|
171
|
+
if (relatedSection) {
|
|
172
|
+
lines.push(relatedSection);
|
|
173
|
+
}
|
|
174
|
+
return lines.join('\n').trim();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Format error response with suggestions
|
|
178
|
+
*/
|
|
179
|
+
function formatNotFoundError(name, suggestions) {
|
|
180
|
+
const lines = [];
|
|
181
|
+
lines.push(`Error: API '${name}' not found.`);
|
|
182
|
+
lines.push('');
|
|
183
|
+
if (suggestions.length > 0) {
|
|
184
|
+
lines.push('Did you mean:');
|
|
185
|
+
for (const api of suggestions) {
|
|
186
|
+
lines.push(`- \`${api.name}\` - ${api.description.slice(0, 60)}${api.description.length > 60 ? '...' : ''}`);
|
|
187
|
+
}
|
|
188
|
+
lines.push('');
|
|
189
|
+
}
|
|
190
|
+
lines.push('Use `list_apis` to see all available APIs.');
|
|
191
|
+
return lines.join('\n');
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Execute get_api tool
|
|
195
|
+
*/
|
|
196
|
+
function executeGetApi(index, input) {
|
|
197
|
+
try {
|
|
198
|
+
const { name } = input;
|
|
199
|
+
const nameLower = name.toLowerCase();
|
|
200
|
+
// Try case-insensitive lookup
|
|
201
|
+
let api;
|
|
202
|
+
for (const [apiName, apiDef] of index.apis) {
|
|
203
|
+
if (apiName.toLowerCase() === nameLower) {
|
|
204
|
+
api = apiDef;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// If found, return documentation
|
|
209
|
+
if (api) {
|
|
210
|
+
return {
|
|
211
|
+
content: formatApiDocumentation(api),
|
|
212
|
+
isError: false,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// Not found - try fuzzy matching
|
|
216
|
+
const suggestions = (0, search_js_1.findSimilarApis)(name, index.apis, 3, 3);
|
|
217
|
+
return {
|
|
218
|
+
content: formatNotFoundError(name, suggestions),
|
|
219
|
+
isError: true,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
return {
|
|
224
|
+
content: `Error retrieving API: ${error instanceof Error ? error.message : String(error)}`,
|
|
225
|
+
isError: true,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=get-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-api.js","sourceRoot":"","sources":["../../src/tools/get-api.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAwNH,sCAsCC;AA5PD,6BAAwB;AAExB,oDAAuD;AAEvD;;GAEG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;SAClC,GAAG,CAAC,GAAG,EAAE,iCAA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KAAK,SAAS,EAAE,CAAC;gBACxC,GAAG,GAAG,MAAM,CAAC;gBACb,MAAM;YACR,CAAC;QACH,CAAC;QAED,iCAAiC;QACjC,IAAI,GAAG,EAAE,CAAC;YACR,OAAO;gBACL,OAAO,EAAE,sBAAsB,CAAC,GAAG,CAAC;gBACpC,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,MAAM,WAAW,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5D,OAAO;YACL,OAAO,EAAE,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC;YAC/C,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC1F,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* list_apis MCP Tool
|
|
3
|
+
*
|
|
4
|
+
* List all available API methods and properties with optional filtering.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { SearchIndex } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Input schema for list_apis tool
|
|
10
|
+
*/
|
|
11
|
+
export declare const listApisInputSchema: z.ZodObject<{
|
|
12
|
+
category: z.ZodDefault<z.ZodEnum<["all", "device-info", "battery", "memory", "storage", "network", "capabilities", "application", "platform-specific", "display", "audio", "location", "identification"]>>;
|
|
13
|
+
platform: z.ZodDefault<z.ZodEnum<["all", "ios", "android", "both"]>>;
|
|
14
|
+
kind: z.ZodDefault<z.ZodEnum<["all", "method", "property"]>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
category: "device-info" | "battery" | "memory" | "storage" | "network" | "capabilities" | "application" | "platform-specific" | "display" | "audio" | "location" | "identification" | "all";
|
|
17
|
+
kind: "method" | "property" | "all";
|
|
18
|
+
platform: "both" | "ios" | "android" | "all";
|
|
19
|
+
}, {
|
|
20
|
+
category?: "device-info" | "battery" | "memory" | "storage" | "network" | "capabilities" | "application" | "platform-specific" | "display" | "audio" | "location" | "identification" | "all" | undefined;
|
|
21
|
+
kind?: "method" | "property" | "all" | undefined;
|
|
22
|
+
platform?: "both" | "ios" | "android" | "all" | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export type ListApisInput = z.infer<typeof listApisInputSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Execute list_apis tool
|
|
27
|
+
*/
|
|
28
|
+
export declare function executeListApis(index: SearchIndex, input: ListApisInput): {
|
|
29
|
+
content: string;
|
|
30
|
+
isError: boolean;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=list-apis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-apis.d.ts","sourceRoot":"","sources":["../../src/tools/list-apis.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAA8B,MAAM,mBAAmB,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EA2B9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AA0FhE;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,aAAa,GACnB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAmGvC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* list_apis MCP Tool
|
|
4
|
+
*
|
|
5
|
+
* List all available API methods and properties with optional filtering.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.listApisInputSchema = void 0;
|
|
9
|
+
exports.executeListApis = executeListApis;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
/**
|
|
12
|
+
* Input schema for list_apis tool
|
|
13
|
+
*/
|
|
14
|
+
exports.listApisInputSchema = zod_1.z.object({
|
|
15
|
+
category: zod_1.z
|
|
16
|
+
.enum([
|
|
17
|
+
'all',
|
|
18
|
+
'device-info',
|
|
19
|
+
'battery',
|
|
20
|
+
'memory',
|
|
21
|
+
'storage',
|
|
22
|
+
'network',
|
|
23
|
+
'capabilities',
|
|
24
|
+
'application',
|
|
25
|
+
'platform-specific',
|
|
26
|
+
'display',
|
|
27
|
+
'audio',
|
|
28
|
+
'location',
|
|
29
|
+
'identification',
|
|
30
|
+
])
|
|
31
|
+
.default('all')
|
|
32
|
+
.describe('Filter by API category'),
|
|
33
|
+
platform: zod_1.z
|
|
34
|
+
.enum(['all', 'ios', 'android', 'both'])
|
|
35
|
+
.default('all')
|
|
36
|
+
.describe("Filter by platform support: 'ios' = iOS only, 'android' = Android only, 'both' = must support both, 'all' = any platform"),
|
|
37
|
+
kind: zod_1.z
|
|
38
|
+
.enum(['all', 'method', 'property'])
|
|
39
|
+
.default('all')
|
|
40
|
+
.describe("Filter by API kind: 'method' = functions with (), 'property' = readonly getters"),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Category display names
|
|
44
|
+
*/
|
|
45
|
+
const CATEGORY_NAMES = {
|
|
46
|
+
'device-info': 'Device Info',
|
|
47
|
+
'battery': 'Battery & Power',
|
|
48
|
+
'memory': 'Memory',
|
|
49
|
+
'storage': 'Storage',
|
|
50
|
+
'network': 'Network',
|
|
51
|
+
'capabilities': 'Capabilities',
|
|
52
|
+
'application': 'Application',
|
|
53
|
+
'platform-specific': 'Platform-Specific',
|
|
54
|
+
'display': 'Display',
|
|
55
|
+
'audio': 'Audio',
|
|
56
|
+
'location': 'Location',
|
|
57
|
+
'identification': 'Identification',
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Format platform info for table
|
|
61
|
+
*/
|
|
62
|
+
function formatPlatformShort(api) {
|
|
63
|
+
const platform = api.platform;
|
|
64
|
+
switch (platform.type) {
|
|
65
|
+
case 'both':
|
|
66
|
+
return 'iOS, Android';
|
|
67
|
+
case 'ios':
|
|
68
|
+
return platform.minVersion ? `iOS ${platform.minVersion}+` : 'iOS';
|
|
69
|
+
case 'android':
|
|
70
|
+
return platform.minApiLevel ? `API ${platform.minApiLevel}+` : 'Android';
|
|
71
|
+
case 'ios-only':
|
|
72
|
+
return 'iOS only';
|
|
73
|
+
case 'android-only':
|
|
74
|
+
return 'Android only';
|
|
75
|
+
default:
|
|
76
|
+
return 'iOS, Android';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if API matches platform filter
|
|
81
|
+
*/
|
|
82
|
+
function matchesPlatform(api, filter) {
|
|
83
|
+
const platformType = api.platform.type;
|
|
84
|
+
switch (filter) {
|
|
85
|
+
case 'all':
|
|
86
|
+
return true;
|
|
87
|
+
case 'ios':
|
|
88
|
+
return platformType === 'ios' || platformType === 'ios-only' || platformType === 'both';
|
|
89
|
+
case 'android':
|
|
90
|
+
return platformType === 'android' || platformType === 'android-only' || platformType === 'both';
|
|
91
|
+
case 'both':
|
|
92
|
+
return platformType === 'both';
|
|
93
|
+
default:
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Format API list by category
|
|
99
|
+
*/
|
|
100
|
+
function formatApisByCategory(apis, category) {
|
|
101
|
+
const lines = [];
|
|
102
|
+
const displayName = CATEGORY_NAMES[category] || category;
|
|
103
|
+
lines.push(`## ${displayName}`);
|
|
104
|
+
lines.push('');
|
|
105
|
+
lines.push('| API | Kind | Platform | Description |');
|
|
106
|
+
lines.push('|-----|------|----------|-------------|');
|
|
107
|
+
for (const api of apis) {
|
|
108
|
+
const name = api.kind === 'method' ? `\`${api.name}()\`` : `\`${api.name}\``;
|
|
109
|
+
const kind = api.kind;
|
|
110
|
+
const platform = formatPlatformShort(api);
|
|
111
|
+
const description = api.description.length > 50
|
|
112
|
+
? api.description.slice(0, 50) + '...'
|
|
113
|
+
: api.description;
|
|
114
|
+
lines.push(`| ${name} | ${kind} | ${platform} | ${description} |`);
|
|
115
|
+
}
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Execute list_apis tool
|
|
120
|
+
*/
|
|
121
|
+
function executeListApis(index, input) {
|
|
122
|
+
try {
|
|
123
|
+
const { category, platform, kind } = input;
|
|
124
|
+
// Filter APIs
|
|
125
|
+
const filteredApis = [];
|
|
126
|
+
for (const [, api] of index.apis) {
|
|
127
|
+
// Category filter
|
|
128
|
+
if (category !== 'all' && api.category !== category) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// Platform filter
|
|
132
|
+
if (!matchesPlatform(api, platform)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Kind filter
|
|
136
|
+
if (kind !== 'all' && api.kind !== kind) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
filteredApis.push(api);
|
|
140
|
+
}
|
|
141
|
+
// Handle no results
|
|
142
|
+
if (filteredApis.length === 0) {
|
|
143
|
+
const lines = [];
|
|
144
|
+
lines.push('No APIs found matching filters:');
|
|
145
|
+
lines.push(`- Category: ${category}`);
|
|
146
|
+
lines.push(`- Platform: ${platform}`);
|
|
147
|
+
lines.push(`- Kind: ${kind}`);
|
|
148
|
+
lines.push('');
|
|
149
|
+
lines.push('Try broadening your filters or use `search_docs` for natural language search.');
|
|
150
|
+
return {
|
|
151
|
+
content: lines.join('\n'),
|
|
152
|
+
isError: false,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// Group by category
|
|
156
|
+
const byCategory = new Map();
|
|
157
|
+
for (const api of filteredApis) {
|
|
158
|
+
const cat = api.category;
|
|
159
|
+
if (!byCategory.has(cat)) {
|
|
160
|
+
byCategory.set(cat, []);
|
|
161
|
+
}
|
|
162
|
+
byCategory.get(cat).push(api);
|
|
163
|
+
}
|
|
164
|
+
// Sort APIs within each category
|
|
165
|
+
for (const [, apis] of byCategory) {
|
|
166
|
+
apis.sort((a, b) => a.name.localeCompare(b.name));
|
|
167
|
+
}
|
|
168
|
+
// Format output
|
|
169
|
+
const lines = [];
|
|
170
|
+
lines.push('# Available APIs');
|
|
171
|
+
lines.push('');
|
|
172
|
+
lines.push(`**Filters**: Category: ${category} | Platform: ${platform} | Kind: ${kind}`);
|
|
173
|
+
lines.push(`**Total**: ${filteredApis.length} APIs`);
|
|
174
|
+
lines.push('');
|
|
175
|
+
// Define category order
|
|
176
|
+
const categoryOrder = [
|
|
177
|
+
'device-info',
|
|
178
|
+
'battery',
|
|
179
|
+
'memory',
|
|
180
|
+
'storage',
|
|
181
|
+
'network',
|
|
182
|
+
'capabilities',
|
|
183
|
+
'application',
|
|
184
|
+
'platform-specific',
|
|
185
|
+
'display',
|
|
186
|
+
'audio',
|
|
187
|
+
'location',
|
|
188
|
+
'identification',
|
|
189
|
+
];
|
|
190
|
+
// Output categories in order
|
|
191
|
+
for (const cat of categoryOrder) {
|
|
192
|
+
const apis = byCategory.get(cat);
|
|
193
|
+
if (apis && apis.length > 0) {
|
|
194
|
+
lines.push(formatApisByCategory(apis, cat));
|
|
195
|
+
lines.push('');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
content: lines.join('\n').trim(),
|
|
200
|
+
isError: false,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return {
|
|
205
|
+
content: `Error listing APIs: ${error instanceof Error ? error.message : String(error)}`,
|
|
206
|
+
isError: true,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=list-apis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-apis.js","sourceRoot":"","sources":["../../src/tools/list-apis.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkIH,0CAsGC;AAtOD,6BAAwB;AAGxB;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,OAAC;SACR,IAAI,CAAC;QACJ,KAAK;QACL,aAAa;QACb,SAAS;QACT,QAAQ;QACR,SAAS;QACT,SAAS;QACT,cAAc;QACd,aAAa;QACb,mBAAmB;QACnB,SAAS;QACT,OAAO;QACP,UAAU;QACV,gBAAgB;KACjB,CAAC;SACD,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,wBAAwB,CAAC;IACrC,QAAQ,EAAE,OAAC;SACR,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;SACvC,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,0HAA0H,CAAC;IACvI,IAAI,EAAE,OAAC;SACJ,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;SACnC,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,iFAAiF,CAAC;CAC/F,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,cAAc,GAAgC;IAClD,aAAa,EAAE,aAAa;IAC5B,SAAS,EAAE,iBAAiB;IAC5B,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,aAAa;IAC5B,mBAAmB,EAAE,mBAAmB;IACxC,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,OAAO;IAChB,U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AAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YAChC,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACxF,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* search_docs MCP Tool
|
|
3
|
+
*
|
|
4
|
+
* Search documentation using natural language queries with BM25 ranking.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { SearchIndex } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Input schema for search_docs tool
|
|
10
|
+
*/
|
|
11
|
+
export declare const searchDocsInputSchema: z.ZodObject<{
|
|
12
|
+
query: z.ZodString;
|
|
13
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
type: z.ZodDefault<z.ZodEnum<["all", "api", "guide"]>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
query: string;
|
|
17
|
+
limit: number;
|
|
18
|
+
type: "api" | "guide" | "all";
|
|
19
|
+
}, {
|
|
20
|
+
query: string;
|
|
21
|
+
limit?: number | undefined;
|
|
22
|
+
type?: "api" | "guide" | "all" | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export type SearchDocsInput = z.infer<typeof searchDocsInputSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Execute search_docs tool
|
|
27
|
+
*/
|
|
28
|
+
export declare function executeSearchDocs(index: SearchIndex, input: SearchDocsInput): {
|
|
29
|
+
content: string;
|
|
30
|
+
isError: boolean;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=search-docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-docs.d.ts","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAqC,MAAM,mBAAmB,CAAC;AAGxF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAiBhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAmFpE;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,eAAe,GACrB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA+CvC"}
|