@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,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* search_docs MCP Tool
|
|
4
|
+
*
|
|
5
|
+
* Search documentation using natural language queries with BM25 ranking.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.searchDocsInputSchema = void 0;
|
|
9
|
+
exports.executeSearchDocs = executeSearchDocs;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const search_js_1 = require("../indexer/search.js");
|
|
12
|
+
/**
|
|
13
|
+
* Input schema for search_docs tool
|
|
14
|
+
*/
|
|
15
|
+
exports.searchDocsInputSchema = zod_1.z.object({
|
|
16
|
+
query: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1, 'Query cannot be empty')
|
|
19
|
+
.max(1000, 'Query exceeds maximum length of 1000 characters')
|
|
20
|
+
.describe("Natural language search query (e.g., 'how to get battery level')"),
|
|
21
|
+
limit: zod_1.z
|
|
22
|
+
.number()
|
|
23
|
+
.int()
|
|
24
|
+
.min(1)
|
|
25
|
+
.max(20)
|
|
26
|
+
.default(5)
|
|
27
|
+
.describe('Maximum number of results to return. If fewer results exist, returns all available.'),
|
|
28
|
+
type: zod_1.z
|
|
29
|
+
.enum(['all', 'api', 'guide'])
|
|
30
|
+
.default('all')
|
|
31
|
+
.describe("Filter results by content type: 'api' = API definitions, 'guide' = documentation guides, 'all' = both"),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Format platform info for display
|
|
35
|
+
*/
|
|
36
|
+
function formatPlatform(api) {
|
|
37
|
+
const platform = api.platform;
|
|
38
|
+
switch (platform.type) {
|
|
39
|
+
case 'both':
|
|
40
|
+
return 'iOS, Android';
|
|
41
|
+
case 'ios':
|
|
42
|
+
return platform.minVersion ? `iOS ${platform.minVersion}+` : 'iOS';
|
|
43
|
+
case 'android':
|
|
44
|
+
return platform.minApiLevel ? `Android API ${platform.minApiLevel}+` : 'Android';
|
|
45
|
+
case 'ios-only':
|
|
46
|
+
return platform.minVersion ? `iOS ${platform.minVersion}+ only` : 'iOS only';
|
|
47
|
+
case 'android-only':
|
|
48
|
+
return platform.minApiLevel ? `Android API ${platform.minApiLevel}+ only` : 'Android only';
|
|
49
|
+
default:
|
|
50
|
+
return 'iOS, Android';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format a single API search result
|
|
55
|
+
*/
|
|
56
|
+
function formatApiResult(api, score, index) {
|
|
57
|
+
const lines = [];
|
|
58
|
+
lines.push(`### ${index}. ${api.name}() (API)`);
|
|
59
|
+
lines.push(`**Relevance**: ${score}%`);
|
|
60
|
+
lines.push(`**Platform**: ${formatPlatform(api)}`);
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push(api.description);
|
|
63
|
+
lines.push('');
|
|
64
|
+
// Add signature
|
|
65
|
+
lines.push('```typescript');
|
|
66
|
+
lines.push(api.signature);
|
|
67
|
+
lines.push('```');
|
|
68
|
+
return lines.join('\n');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Format a single documentation chunk search result
|
|
72
|
+
*/
|
|
73
|
+
function formatDocResult(chunk, score, index) {
|
|
74
|
+
const lines = [];
|
|
75
|
+
const typeLabel = chunk.type === 'api' ? 'API' : chunk.type === 'troubleshooting' ? 'Troubleshooting' : 'Guide';
|
|
76
|
+
lines.push(`### ${index}. ${chunk.title} (${typeLabel})`);
|
|
77
|
+
lines.push(`**Relevance**: ${score}%`);
|
|
78
|
+
if (chunk.platforms.length > 0) {
|
|
79
|
+
lines.push(`**Platform**: ${chunk.platforms.map(p => p === 'ios' ? 'iOS' : 'Android').join(', ')}`);
|
|
80
|
+
}
|
|
81
|
+
lines.push('');
|
|
82
|
+
// Truncate content for display
|
|
83
|
+
const excerpt = chunk.content.length > 300
|
|
84
|
+
? chunk.content.slice(0, 300) + '...'
|
|
85
|
+
: chunk.content;
|
|
86
|
+
lines.push(excerpt);
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get suggested search terms when no results found
|
|
91
|
+
*/
|
|
92
|
+
function getSuggestions() {
|
|
93
|
+
return `Try searching for:
|
|
94
|
+
- Battery: getBatteryLevel, isCharging, powerState
|
|
95
|
+
- Device: deviceId, model, brand
|
|
96
|
+
- Network: ipAddress, carrier, macAddress
|
|
97
|
+
- Memory: totalMemory, usedMemory
|
|
98
|
+
- Storage: diskCapacity, freeDiskStorage`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Execute search_docs tool
|
|
102
|
+
*/
|
|
103
|
+
function executeSearchDocs(index, input) {
|
|
104
|
+
try {
|
|
105
|
+
const { query, limit, type } = input;
|
|
106
|
+
// Perform search
|
|
107
|
+
const results = (0, search_js_1.search)(index, query, limit, {
|
|
108
|
+
type: type === 'api' ? 'api' : type === 'guide' ? 'guide' : 'all',
|
|
109
|
+
});
|
|
110
|
+
// Handle no results
|
|
111
|
+
if (results.length === 0) {
|
|
112
|
+
return {
|
|
113
|
+
content: `No results found for "${query}".\n\n${getSuggestions()}`,
|
|
114
|
+
isError: false,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// Format results
|
|
118
|
+
const lines = [];
|
|
119
|
+
lines.push(`## Search Results for "${query}"`);
|
|
120
|
+
lines.push('');
|
|
121
|
+
lines.push(`Found ${results.length} result${results.length === 1 ? '' : 's'}:`);
|
|
122
|
+
lines.push('');
|
|
123
|
+
let resultIndex = 1;
|
|
124
|
+
for (const result of results) {
|
|
125
|
+
if (result.type === 'api') {
|
|
126
|
+
lines.push(formatApiResult(result.item, result.score, resultIndex));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
lines.push(formatDocResult(result.item, result.score, resultIndex));
|
|
130
|
+
}
|
|
131
|
+
lines.push('');
|
|
132
|
+
lines.push('---');
|
|
133
|
+
lines.push('');
|
|
134
|
+
resultIndex++;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
content: lines.join('\n').trim(),
|
|
138
|
+
isError: false,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return {
|
|
143
|
+
content: `Error searching documentation: ${error instanceof Error ? error.message : String(error)}`,
|
|
144
|
+
isError: true,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=search-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-docs.js","sourceRoot":"","sources":["../../src/tools/search-docs.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkHH,8CAkDC;AAlKD,6BAAwB;AAExB,oDAA8C;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,GAAG,CAAC,IAAI,EAAE,iDAAiD,CAAC;SAC5D,QAAQ,CAAC,kEAAkE,CAAC;IAC/E,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC,qFAAqF,CAAC;IAClG,IAAI,EAAE,OAAC;SACJ,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;SAC7B,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,uGAAuG,CAAC;CACrH,CAAC,CAAC;AAIH;;GAEG;AACH,SAAS,cAAc,CAAC,GAAkB;IACxC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,cAAc,CAAC;QACxB,KAAK,KAAK;YACR,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,CA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,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAA0B,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;YAC5F,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,WAAW,EAAE,CAAC;QAChB,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,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACnG,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Types for react-native-nitro-device-info
|
|
3
|
+
*
|
|
4
|
+
* These types define the data structures used by the MCP server
|
|
5
|
+
* for indexing and serving documentation.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parameter definition for API methods
|
|
9
|
+
*/
|
|
10
|
+
export interface Parameter {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
optional: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Platform availability information
|
|
18
|
+
*/
|
|
19
|
+
export type Platform = {
|
|
20
|
+
type: 'both';
|
|
21
|
+
} | {
|
|
22
|
+
type: 'ios';
|
|
23
|
+
minVersion?: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'android';
|
|
26
|
+
minApiLevel?: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'ios-only';
|
|
29
|
+
minVersion?: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'android-only';
|
|
32
|
+
minApiLevel?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* API categories for grouping
|
|
36
|
+
*/
|
|
37
|
+
export type ApiCategory = 'device-info' | 'battery' | 'memory' | 'storage' | 'network' | 'capabilities' | 'application' | 'platform-specific' | 'display' | 'audio' | 'location' | 'identification';
|
|
38
|
+
/**
|
|
39
|
+
* Represents a single API method or property from the DeviceInfo interface
|
|
40
|
+
*/
|
|
41
|
+
export interface ApiDefinition {
|
|
42
|
+
/** Unique identifier (method/property name) */
|
|
43
|
+
name: string;
|
|
44
|
+
/** Human-readable description from JSDoc */
|
|
45
|
+
description: string;
|
|
46
|
+
/** Whether this is a method or readonly property */
|
|
47
|
+
kind: 'method' | 'property';
|
|
48
|
+
/** TypeScript signature */
|
|
49
|
+
signature: string;
|
|
50
|
+
/** Return type */
|
|
51
|
+
returnType: string;
|
|
52
|
+
/** Method parameters (empty for properties) */
|
|
53
|
+
parameters: Parameter[];
|
|
54
|
+
/** Platform availability */
|
|
55
|
+
platform: Platform;
|
|
56
|
+
/** Whether method is async (returns Promise) */
|
|
57
|
+
isAsync: boolean;
|
|
58
|
+
/** Code examples from JSDoc @example tags */
|
|
59
|
+
examples: string[];
|
|
60
|
+
/** Related API names for cross-reference */
|
|
61
|
+
relatedApis: string[];
|
|
62
|
+
/** Category for grouping */
|
|
63
|
+
category: ApiCategory;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Document type for search results
|
|
67
|
+
*/
|
|
68
|
+
export type DocumentType = 'api' | 'guide' | 'example' | 'troubleshooting';
|
|
69
|
+
/**
|
|
70
|
+
* Represents a searchable section of documentation
|
|
71
|
+
*/
|
|
72
|
+
export interface DocumentationChunk {
|
|
73
|
+
/** Unique identifier */
|
|
74
|
+
id: string;
|
|
75
|
+
/** Source file path relative to repo root */
|
|
76
|
+
source: string;
|
|
77
|
+
/** Heading/title of this chunk */
|
|
78
|
+
title: string;
|
|
79
|
+
/** Full text content for search */
|
|
80
|
+
content: string;
|
|
81
|
+
/** Document type */
|
|
82
|
+
type: DocumentType;
|
|
83
|
+
/** Heading level (1-6) */
|
|
84
|
+
headingLevel: number;
|
|
85
|
+
/** Parent chunk ID for hierarchy */
|
|
86
|
+
parentId?: string;
|
|
87
|
+
/** API names mentioned in this chunk */
|
|
88
|
+
mentionedApis: string[];
|
|
89
|
+
/** Platform tags if applicable */
|
|
90
|
+
platforms: ('ios' | 'android')[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Highlight information for search results
|
|
94
|
+
*/
|
|
95
|
+
export interface Highlight {
|
|
96
|
+
/** Field that matched */
|
|
97
|
+
field: string;
|
|
98
|
+
/** Text excerpt with match markers */
|
|
99
|
+
excerpt: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Represents a ranked search result
|
|
103
|
+
*/
|
|
104
|
+
export interface SearchResult {
|
|
105
|
+
/** The matched item */
|
|
106
|
+
item: ApiDefinition | DocumentationChunk;
|
|
107
|
+
/** BM25 relevance score (0-100 normalized) */
|
|
108
|
+
score: number;
|
|
109
|
+
/** Type discriminator */
|
|
110
|
+
type: 'api' | 'documentation';
|
|
111
|
+
/** Matching excerpts with highlights */
|
|
112
|
+
highlights: Highlight[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* In-memory search index structure
|
|
116
|
+
*/
|
|
117
|
+
export interface SearchIndex {
|
|
118
|
+
/** All indexed API definitions */
|
|
119
|
+
apis: Map<string, ApiDefinition>;
|
|
120
|
+
/** All documentation chunks */
|
|
121
|
+
chunks: DocumentationChunk[];
|
|
122
|
+
/** BM25 inverted index: term -> document IDs */
|
|
123
|
+
invertedIndex: Map<string, Set<string>>;
|
|
124
|
+
/** Document lengths for BM25 */
|
|
125
|
+
documentLengths: Map<string, number>;
|
|
126
|
+
/** Average document length */
|
|
127
|
+
averageDocumentLength: number;
|
|
128
|
+
/** Total document count */
|
|
129
|
+
documentCount: number;
|
|
130
|
+
/** Term document frequencies for IDF calculation */
|
|
131
|
+
termDocumentFrequencies: Map<string, number>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Search filter options
|
|
135
|
+
*/
|
|
136
|
+
export interface SearchFilters {
|
|
137
|
+
/** Filter by content type */
|
|
138
|
+
type?: 'all' | 'api' | 'guide';
|
|
139
|
+
/** Filter by platform */
|
|
140
|
+
platform?: 'all' | 'ios' | 'android' | 'both';
|
|
141
|
+
/** Filter by API category */
|
|
142
|
+
category?: ApiCategory | 'all';
|
|
143
|
+
/** Filter by API kind */
|
|
144
|
+
kind?: 'all' | 'method' | 'property';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Device types from the library
|
|
148
|
+
*/
|
|
149
|
+
export type DeviceType = 'Handset' | 'Tablet' | 'Tv' | 'Desktop' | 'GamingConsole' | 'unknown';
|
|
150
|
+
/**
|
|
151
|
+
* Battery charging states
|
|
152
|
+
*/
|
|
153
|
+
export type BatteryState = 'unknown' | 'unplugged' | 'charging' | 'full';
|
|
154
|
+
/**
|
|
155
|
+
* Android navigation mode types
|
|
156
|
+
*/
|
|
157
|
+
export type NavigationMode = 'gesture' | 'buttons' | 'twobuttons' | 'unknown';
|
|
158
|
+
/**
|
|
159
|
+
* Power state information
|
|
160
|
+
*/
|
|
161
|
+
export interface PowerState {
|
|
162
|
+
batteryLevel: number;
|
|
163
|
+
batteryState: BatteryState;
|
|
164
|
+
lowPowerMode: boolean;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAA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C;IAExC,gCAAgC;IAChC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAErC,8BAA8B;IAC9B,qBAAqB,EAAE,MAAM,CAAC;IAE9B,2BAA2B;IAC3B,aAAa,EAAE,MAAM,CAAC;IAEtB,oDAAoD;IACpD,uBAAuB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;IAE/B,yBAAyB;IACzB,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;IAE9C,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAE/B,yBAAyB;IACzB,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,IAAI,GACJ,SAAS,GACT,eAAe,GACf,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server Types for react-native-nitro-device-info
|
|
4
|
+
*
|
|
5
|
+
* These types define the data structures used by the MCP server
|
|
6
|
+
* for indexing and serving documentation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-nitro-device-info/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for react-native-nitro-device-info AI tool integration",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"nitro-device-info-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"test:watch": "jest --watch",
|
|
21
|
+
"test:coverage": "jest --coverage",
|
|
22
|
+
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"mcp",
|
|
27
|
+
"model-context-protocol",
|
|
28
|
+
"react-native",
|
|
29
|
+
"react-native-nitro-device-info",
|
|
30
|
+
"ai",
|
|
31
|
+
"claude",
|
|
32
|
+
"cursor"
|
|
33
|
+
],
|
|
34
|
+
"author": "HyunWoo Lee <l2hyunwoo@gmail.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/l2hyunwoo/react-native-nitro-device-info.git",
|
|
39
|
+
"directory": "packages/mcp-server"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/l2hyunwoo/react-native-nitro-device-info/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/l2hyunwoo/react-native-nitro-device-info#readme",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20.0.0"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
50
|
+
"zod": "^3.25.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/jest": "^29.5.14",
|
|
54
|
+
"@types/node": "^20.0.0",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"ts-jest": "^29.1.0",
|
|
57
|
+
"typescript": "^5.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|