node-opcua-modeler-mcp-server 1.0.1 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-modeler-mcp-server",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "mcpName": "io.github.node-opcua/node-opcua-modeler-mcp-server",
5
5
  "description": "OPC UA Modeler MCP Server — exposes companion spec tools to AI agents",
6
6
  "type": "module",
@@ -18,25 +18,12 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "tsc",
21
- "test": "vitest run",
22
- "test:watch": "vitest",
23
- "start": "node dist/index.js",
24
- "extract-catalog": "tsx scripts/extract-catalog.ts",
25
- "demo": "tsx scripts/demo.ts"
21
+ "start": "node dist/index.js"
26
22
  },
27
23
  "dependencies": {
28
24
  "@modelcontextprotocol/sdk": "^1.12.1",
29
25
  "zod": "^3.25.0"
30
26
  },
31
- "devDependencies": {
32
- "@sterfive/opcua-modeler-ex": "workspace:*",
33
- "@sterfive/opcua-modeler-knowledge-base": "workspace:*",
34
- "node-opcua-address-space": "2.173.1",
35
- "node-opcua-data-model": "2.173.0",
36
- "tsx": "^4.19.0",
37
- "vitest": "^3.2.2",
38
- "typescript": "~5.7.3"
39
- },
40
27
  "keywords": [
41
28
  "opcua",
42
29
  "opc-ua",
package/server.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
3
3
  "name": "io.github.node-opcua/node-opcua-modeler-mcp-server",
4
4
  "title": "OPC UA Modeler",
5
- "description": "Discover OPC UA companion spec types, resolve namespace dependencies, and look up engineering units for AI-assisted industrial automation modeling",
6
- "version": "1.0.0",
5
+ "description": "OPC UA companion spec types, namespace dependencies, and engineering units for AI agents",
6
+ "version": "1.2.0",
7
7
  "websiteUrl": "https://opcua-modeler.sterfive.com",
8
8
  "repository": {
9
9
  "url": "https://github.com/node-opcua/node-opcua-modeler-mcp-server",
@@ -13,7 +13,7 @@
13
13
  {
14
14
  "registryType": "npm",
15
15
  "identifier": "node-opcua-modeler-mcp-server",
16
- "version": "1.0.0",
16
+ "version": "1.2.0",
17
17
  "registryBaseUrl": "https://registry.npmjs.org",
18
18
  "runtimeHint": "npx",
19
19
  "transport": {
package/dist/catalog.d.ts DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- * ==========================================================================
3
- * OPC UA Modeler MCP Server — Static Catalog Loader
4
- *
5
- * Loads the pre-generated catalog.json that contains all public OPC UA
6
- * companion spec type information. This file is generated at build time
7
- * by scripts/extract-catalog.ts and committed to git.
8
- *
9
- * IMPORTANT: This module has ZERO dependencies on @sterfive/* packages.
10
- * All data comes from the static JSON catalog.
11
- * ==========================================================================
12
- */
13
- export interface CompanionSpecEntry {
14
- alias: string;
15
- name: string;
16
- uri: string;
17
- deps: string[];
18
- keywords: string[];
19
- priority: 0 | 1 | 2;
20
- }
21
- export interface TypeSummary {
22
- browseName: string;
23
- kind: "ObjectType" | "VariableType" | "ReferenceType" | "DataType";
24
- namespace: string;
25
- isAbstract: boolean;
26
- description?: string;
27
- subtypeOf?: string;
28
- }
29
- export interface MemberSummary {
30
- browseName: string;
31
- nodeClass: string;
32
- dataType?: string;
33
- typeDefinition?: string;
34
- modellingRule?: string;
35
- description?: string;
36
- }
37
- export interface TypeDetails extends TypeSummary {
38
- components: MemberSummary[];
39
- properties: MemberSummary[];
40
- methods: string[];
41
- interfaces: string[];
42
- }
43
- export interface EngineeringUnitsData {
44
- symbols: string[];
45
- aliases: Record<string, string>;
46
- }
47
- export interface Catalog {
48
- version: string;
49
- generatedAt: string;
50
- registry: CompanionSpecEntry[];
51
- types: Record<string, TypeSummary[]>;
52
- typeDetails: Record<string, Record<string, TypeDetails>>;
53
- engineeringUnits: EngineeringUnitsData;
54
- }
55
- /** List all companion spec namespaces */
56
- export declare function listNamespaces(): CompanionSpecEntry[];
57
- /**
58
- * Resolve the full dependency chain for a set of spec aliases.
59
- * Returns a topologically sorted list (dependencies before dependents).
60
- */
61
- export declare function resolveDependencies(aliases: string[]): string[];
62
- /** List all types in a companion spec namespace */
63
- export declare function listTypes(alias: string): TypeSummary[];
64
- /** Get detailed information about a specific type */
65
- export declare function getTypeDetails(alias: string, browseName: string): TypeDetails | null;
66
- /** Search for types across all companion specs by keyword */
67
- export declare function searchTypes(query: string): (TypeSummary & {
68
- alias: string;
69
- })[];
70
- export interface UnitLookupResult {
71
- symbol: string;
72
- matchType: "exact" | "case-insensitive" | "alias" | "fuzzy";
73
- confidence: number;
74
- }
75
- /** Find the official engineering unit symbol for a description */
76
- export declare function findEngineeringUnit(query: string): UnitLookupResult | null;
package/dist/catalog.js DELETED
@@ -1,134 +0,0 @@
1
- /**
2
- * ==========================================================================
3
- * OPC UA Modeler MCP Server — Static Catalog Loader
4
- *
5
- * Loads the pre-generated catalog.json that contains all public OPC UA
6
- * companion spec type information. This file is generated at build time
7
- * by scripts/extract-catalog.ts and committed to git.
8
- *
9
- * IMPORTANT: This module has ZERO dependencies on @sterfive/* packages.
10
- * All data comes from the static JSON catalog.
11
- * ==========================================================================
12
- */
13
- import fs from "node:fs";
14
- import path from "node:path";
15
- import { fileURLToPath } from "node:url";
16
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
- const CATALOG_PATH = path.resolve(__dirname, "..", "catalog", "catalog.json");
18
- // ── Lazy-loaded singleton ────────────────────────────────────────────────
19
- let _catalog = null;
20
- function getCatalog() {
21
- if (!_catalog) {
22
- const raw = fs.readFileSync(CATALOG_PATH, "utf-8");
23
- _catalog = JSON.parse(raw);
24
- }
25
- return _catalog;
26
- }
27
- // ── Public Query API ─────────────────────────────────────────────────────
28
- /** List all companion spec namespaces */
29
- export function listNamespaces() {
30
- return getCatalog().registry;
31
- }
32
- /**
33
- * Resolve the full dependency chain for a set of spec aliases.
34
- * Returns a topologically sorted list (dependencies before dependents).
35
- */
36
- export function resolveDependencies(aliases) {
37
- const registry = getCatalog().registry;
38
- const byAlias = new Map(registry.map((s) => [s.alias, s]));
39
- const resolved = new Set();
40
- const result = [];
41
- function visit(alias) {
42
- if (resolved.has(alias))
43
- return;
44
- const spec = byAlias.get(alias);
45
- if (!spec)
46
- return;
47
- for (const dep of spec.deps) {
48
- visit(dep);
49
- }
50
- resolved.add(alias);
51
- result.push(alias);
52
- }
53
- for (const alias of aliases) {
54
- visit(alias);
55
- }
56
- return result;
57
- }
58
- /** List all types in a companion spec namespace */
59
- export function listTypes(alias) {
60
- return getCatalog().types[alias] ?? [];
61
- }
62
- /** Get detailed information about a specific type */
63
- export function getTypeDetails(alias, browseName) {
64
- const nsDetails = getCatalog().typeDetails[alias];
65
- if (!nsDetails)
66
- return null;
67
- return nsDetails[browseName] ?? null;
68
- }
69
- /** Search for types across all companion specs by keyword */
70
- export function searchTypes(query) {
71
- const catalog = getCatalog();
72
- const results = [];
73
- const q = query.toLowerCase();
74
- for (const [alias, types] of Object.entries(catalog.types)) {
75
- for (const t of types) {
76
- if (t.browseName.toLowerCase().includes(q) ||
77
- (t.description && t.description.toLowerCase().includes(q))) {
78
- results.push({ ...t, alias });
79
- }
80
- }
81
- }
82
- return results;
83
- }
84
- let _unitsLower = null;
85
- function getUnitsLowerMap() {
86
- if (!_unitsLower) {
87
- _unitsLower = new Map();
88
- for (const u of getCatalog().engineeringUnits.symbols) {
89
- _unitsLower.set(String(u).toLowerCase(), String(u));
90
- }
91
- }
92
- return _unitsLower;
93
- }
94
- /** Find the official engineering unit symbol for a description */
95
- export function findEngineeringUnit(query) {
96
- if (!query || query.trim().length === 0)
97
- return null;
98
- const catalog = getCatalog();
99
- const units = catalog.engineeringUnits.symbols.map(String);
100
- const aliases = catalog.engineeringUnits.aliases;
101
- const q = query.trim();
102
- // 1. Exact match
103
- if (units.includes(q)) {
104
- return { symbol: q, matchType: "exact", confidence: 1 };
105
- }
106
- // 2. Case-insensitive match
107
- const lowerMap = getUnitsLowerMap();
108
- const lower = q.toLowerCase();
109
- const ciMatch = lowerMap.get(lower);
110
- if (ciMatch) {
111
- return { symbol: ciMatch, matchType: "case-insensitive", confidence: 0.95 };
112
- }
113
- // 3. Alias match (natural language → symbol)
114
- const aliasMatch = aliases[lower];
115
- if (aliasMatch) {
116
- return { symbol: aliasMatch, matchType: "alias", confidence: 1 };
117
- }
118
- // 4. Fuzzy: strip quotes, whitespace variants
119
- const normalized = q.replace(/['"]/g, "").replace(/\s+/g, " ").toLowerCase();
120
- const aliasNorm = aliases[normalized];
121
- if (aliasNorm) {
122
- return { symbol: aliasNorm, matchType: "alias", confidence: 0.9 };
123
- }
124
- // 5. Fuzzy: try removing trailing 's' (plurals)
125
- if (normalized.endsWith("s")) {
126
- const singular = normalized.slice(0, -1);
127
- const singularMatch = aliases[singular];
128
- if (singularMatch) {
129
- return { symbol: singularMatch, matchType: "fuzzy", confidence: 0.85 };
130
- }
131
- }
132
- return null;
133
- }
134
- //# sourceMappingURL=catalog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAoD9E,4EAA4E;AAE5E,IAAI,QAAQ,GAAmB,IAAI,CAAC;AAEpC,SAAS,UAAU;IACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;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,CAAC;IACnE,CAAC;IAED,8CAA8C;IAC9C,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7E,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;IACpE,CAAC;IAED,gDAAgD;IAChD,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * ==========================================================================
4
- * OPC UA Modeler — MCP Server (CLI Entry Point)
5
- *
6
- * Thin wrapper that creates the server and connects it to stdio transport.
7
- * All tool registration logic lives in server.ts.
8
- *
9
- * Transport: stdio (JSON-RPC over stdin/stdout)
10
- * IMPORTANT: Never use console.log() — stdout is reserved for JSON-RPC.
11
- * ==========================================================================
12
- */
13
- export {};
package/dist/index.js DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * ==========================================================================
4
- * OPC UA Modeler — MCP Server (CLI Entry Point)
5
- *
6
- * Thin wrapper that creates the server and connects it to stdio transport.
7
- * All tool registration logic lives in server.ts.
8
- *
9
- * Transport: stdio (JSON-RPC over stdin/stdout)
10
- * IMPORTANT: Never use console.log() — stdout is reserved for JSON-RPC.
11
- * ==========================================================================
12
- */
13
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
14
- import { createServer } from "./server.js";
15
- async function main() {
16
- const server = createServer();
17
- const transport = new StdioServerTransport();
18
- await server.connect(transport);
19
- console.error("opcua-modeler MCP server running on stdio");
20
- }
21
- main().catch((err) => {
22
- console.error("Fatal error starting MCP server:", err);
23
- process.exit(1);
24
- });
25
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;AAC7D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/server.d.ts DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * ==========================================================================
3
- * OPC UA Modeler — MCP Server Factory (IP-Safe Version)
4
- *
5
- * Creates and configures the MCP server with 6 OPC UA companion-spec
6
- * discovery tools. All data comes from a static catalog.json file —
7
- * ZERO dependencies on proprietary @sterfive/* packages.
8
- *
9
- * Architecture: "Thin Local Shell" per Project Prometheus §1.1
10
- * - Local tools: query the static type catalog (free, offline)
11
- * - Cloud tools: proxy to api.opcua-modeler.sterfive.io (Phase 1b)
12
- *
13
- * IMPORTANT: Never use console.log() — stdout may be reserved for JSON-RPC.
14
- * ==========================================================================
15
- */
16
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
- import { findEngineeringUnit, getTypeDetails, listNamespaces, listTypes, resolveDependencies, searchTypes } from "./catalog.js";
18
- export { findEngineeringUnit, getTypeDetails, listNamespaces, listTypes, resolveDependencies, searchTypes };
19
- /** Tool name type */
20
- export type ToolName = "resolve_dependencies" | "list_namespaces" | "list_types" | "get_type_details" | "search_types" | "find_engineering_unit";
21
- /**
22
- * Direct tool call handler for testing (bypasses MCP protocol).
23
- * Returns the same shape as MCP tool responses.
24
- */
25
- export declare function handleToolCall(name: ToolName, args: Record<string, unknown>): Promise<{
26
- content: {
27
- type: "text";
28
- text: string;
29
- }[];
30
- isError?: undefined;
31
- } | {
32
- content: {
33
- type: "text";
34
- text: string;
35
- }[];
36
- isError: boolean;
37
- }>;
38
- /**
39
- * Create and configure the MCP server with all OPC UA tools registered.
40
- * The server is NOT connected to any transport — the caller is responsible
41
- * for connecting it (e.g., StdioServerTransport or InMemoryTransport).
42
- */
43
- export declare function createServer(): McpServer;
package/dist/server.js DELETED
@@ -1,161 +0,0 @@
1
- /**
2
- * ==========================================================================
3
- * OPC UA Modeler — MCP Server Factory (IP-Safe Version)
4
- *
5
- * Creates and configures the MCP server with 6 OPC UA companion-spec
6
- * discovery tools. All data comes from a static catalog.json file —
7
- * ZERO dependencies on proprietary @sterfive/* packages.
8
- *
9
- * Architecture: "Thin Local Shell" per Project Prometheus §1.1
10
- * - Local tools: query the static type catalog (free, offline)
11
- * - Cloud tools: proxy to api.opcua-modeler.sterfive.io (Phase 1b)
12
- *
13
- * IMPORTANT: Never use console.log() — stdout may be reserved for JSON-RPC.
14
- * ==========================================================================
15
- */
16
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
- import { z } from "zod";
18
- import { findEngineeringUnit, getTypeDetails, listNamespaces, listTypes, resolveDependencies, searchTypes } from "./catalog.js";
19
- // Re-export for testing
20
- export { findEngineeringUnit, getTypeDetails, listNamespaces, listTypes, resolveDependencies, searchTypes };
21
- /**
22
- * Direct tool call handler for testing (bypasses MCP protocol).
23
- * Returns the same shape as MCP tool responses.
24
- */
25
- export async function handleToolCall(name, args) {
26
- try {
27
- switch (name) {
28
- case "resolve_dependencies": {
29
- const aliases = args.aliases;
30
- return { content: [{ type: "text", text: JSON.stringify(resolveDependencies(aliases)) }] };
31
- }
32
- case "list_namespaces": {
33
- const specs = listNamespaces().map((s) => ({
34
- alias: s.alias,
35
- name: s.name,
36
- uri: s.uri,
37
- dependencies: s.deps
38
- }));
39
- return { content: [{ type: "text", text: JSON.stringify(specs) }] };
40
- }
41
- case "list_types": {
42
- return { content: [{ type: "text", text: JSON.stringify(listTypes(args.alias)) }] };
43
- }
44
- case "get_type_details": {
45
- const details = getTypeDetails(args.alias, args.browseName);
46
- if (!details) {
47
- return { content: [{ type: "text", text: JSON.stringify({ error: `Type not found` }) }], isError: true };
48
- }
49
- return { content: [{ type: "text", text: JSON.stringify(details) }] };
50
- }
51
- case "search_types": {
52
- return { content: [{ type: "text", text: JSON.stringify(searchTypes(args.query)) }] };
53
- }
54
- case "find_engineering_unit": {
55
- const result = findEngineeringUnit(String(args.query ?? ""));
56
- if (!result) {
57
- return { content: [{ type: "text", text: JSON.stringify({ error: `No unit found` }) }], isError: true };
58
- }
59
- return { content: [{ type: "text", text: JSON.stringify(result) }] };
60
- }
61
- default:
62
- return { content: [{ type: "text", text: JSON.stringify({ error: `Unknown tool: ${name}` }) }], isError: true };
63
- }
64
- }
65
- catch (e) {
66
- return { content: [{ type: "text", text: JSON.stringify({ error: String(e) }) }], isError: true };
67
- }
68
- }
69
- /**
70
- * Create and configure the MCP server with all OPC UA tools registered.
71
- * The server is NOT connected to any transport — the caller is responsible
72
- * for connecting it (e.g., StdioServerTransport or InMemoryTransport).
73
- */
74
- export function createServer() {
75
- const server = new McpServer({
76
- name: "opcua-modeler",
77
- version: "1.0.0"
78
- });
79
- // ── 1. resolve_dependencies ──────────────────────────────────────────
80
- server.tool("resolve_dependencies", "Given one or more companion spec namespace aliases, returns the full " +
81
- "resolved dependency list that MUST go in the YAML `namespaces:` section. " +
82
- "Always call this before generating the namespaces block.", { aliases: z.array(z.string()).describe('Companion spec aliases to resolve (e.g. ["machineTool", "robotics"])') }, async ({ aliases }) => {
83
- try {
84
- const resolved = resolveDependencies(aliases);
85
- return {
86
- content: [{ type: "text", text: JSON.stringify(resolved) }]
87
- };
88
- }
89
- catch (e) {
90
- return {
91
- content: [{ type: "text", text: JSON.stringify({ error: String(e) }) }],
92
- isError: true
93
- };
94
- }
95
- });
96
- // ── 2. list_namespaces ───────────────────────────────────────────────
97
- server.tool("list_namespaces", "List all well-known OPC UA companion spec namespace aliases with their " +
98
- "full names, URIs, and dependencies. Use this to discover what namespaces are available.", {}, async () => {
99
- const specs = listNamespaces().map((s) => ({
100
- alias: s.alias,
101
- name: s.name,
102
- uri: s.uri,
103
- dependencies: s.deps
104
- }));
105
- return {
106
- content: [{ type: "text", text: JSON.stringify(specs) }]
107
- };
108
- });
109
- // ── 3. list_types ────────────────────────────────────────────────────
110
- server.tool("list_types", "List ALL ObjectTypes, VariableTypes, and InterfaceTypes defined in a " +
111
- "specific companion spec namespace. " +
112
- "ALWAYS call this before using any type from a namespace — NEVER guess type names.", { alias: z.string().describe('Companion spec alias (e.g. "machinery", "di", "robotics")') }, async ({ alias }) => {
113
- const types = listTypes(alias);
114
- return {
115
- content: [{ type: "text", text: JSON.stringify(types) }]
116
- };
117
- });
118
- // ── 4. get_type_details ──────────────────────────────────────────────
119
- server.tool("get_type_details", "Get detailed information about a specific type: its components, properties, " +
120
- "methods, interfaces, and optional members. Use this to understand a type's " +
121
- "structure before creating instances or subtypes.", {
122
- alias: z.string().describe('Companion spec alias where the type is defined (e.g. "machinery")'),
123
- browseName: z.string().describe('The type browse name (e.g. "MachineryItemIdentificationType")')
124
- }, async ({ alias, browseName }) => {
125
- const details = getTypeDetails(alias, browseName);
126
- if (!details) {
127
- return {
128
- content: [{ type: "text", text: JSON.stringify({ error: `Type "${browseName}" not found in "${alias}"` }) }],
129
- isError: true
130
- };
131
- }
132
- return {
133
- content: [{ type: "text", text: JSON.stringify(details) }]
134
- };
135
- });
136
- // ── 5. search_types ──────────────────────────────────────────────────
137
- server.tool("search_types", "Search for types across ALL companion specs by keyword. " +
138
- "Use this when you don't know which namespace defines a type. " +
139
- "Returns matching types with their namespace alias.", { query: z.string().describe('Search keyword (e.g. "identification", "temperature", "motion")') }, async ({ query }) => {
140
- const results = searchTypes(query);
141
- return {
142
- content: [{ type: "text", text: JSON.stringify(results) }]
143
- };
144
- });
145
- // ── 6. find_engineering_unit ──────────────────────────────────────────
146
- server.tool("find_engineering_unit", "Find the official UNECE Rec. 20 engineering unit symbol for a given description. " +
147
- "ALWAYS call this before using any engineering unit — NEVER guess unit symbols.", { query: z.string().describe('Description or common name of the unit (e.g. "revolutions per minute", "celsius", "pressure bar")') }, async ({ query }) => {
148
- const result = findEngineeringUnit(query);
149
- if (!result) {
150
- return {
151
- content: [{ type: "text", text: JSON.stringify({ error: `No unit found for "${query}"` }) }],
152
- isError: true
153
- };
154
- }
155
- return {
156
- content: [{ type: "text", text: JSON.stringify(result) }]
157
- };
158
- });
159
- return server;
160
- }
161
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,WAAW,EAC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