@jlcpcb/mcp 0.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.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Component search tools for MCP
3
+ */
4
+
5
+ import { z } from 'zod';
6
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
7
+ import { jlcClient } from '@jlcpcb/core';
8
+
9
+ export const searchComponentsTool: Tool = {
10
+ name: 'component_search',
11
+ description: 'Search the JLC/JLCPCB component database by keyword. Returns components with LCSC part numbers (JLC\'s preferred supplier for assembly). Includes prices, stock levels, and whether parts are in the Basic Parts Library (lower assembly cost).',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {
15
+ query: {
16
+ type: 'string',
17
+ description: 'Search query (e.g., "ESP32", "STM32F103", "0805 100nF")',
18
+ },
19
+ limit: {
20
+ type: 'number',
21
+ description: 'Maximum number of results (default: 10, max: 50)',
22
+ },
23
+ in_stock: {
24
+ type: 'boolean',
25
+ description: 'Only show in-stock items (default: false)',
26
+ },
27
+ basic_only: {
28
+ type: 'boolean',
29
+ description: 'Only show JLCPCB Basic Parts Library components (lower assembly cost, default: false)',
30
+ },
31
+ },
32
+ required: ['query'],
33
+ },
34
+ };
35
+
36
+ export const SearchParamsSchema = z.object({
37
+ query: z.string().min(1),
38
+ limit: z.number().min(1).max(50).default(10),
39
+ in_stock: z.boolean().optional(),
40
+ basic_only: z.boolean().optional(),
41
+ });
42
+
43
+ export async function handleSearchComponents(args: unknown) {
44
+ const params = SearchParamsSchema.parse(args);
45
+
46
+ const results = await jlcClient.search(params.query, {
47
+ limit: params.limit,
48
+ inStock: params.in_stock,
49
+ basicOnly: params.basic_only,
50
+ });
51
+
52
+ return {
53
+ content: [{
54
+ type: 'text' as const,
55
+ text: JSON.stringify(results, null, 2),
56
+ }],
57
+ };
58
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["src/browser/**/*"]
9
+ }