@dotzero.ai/dotzero-mcp 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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared authentication state for all DotZero services.
3
+ * One JWT token works across all DotZero APIs.
4
+ */
5
+ import { AxiosInstance } from "axios";
6
+ export interface ServiceConfig {
7
+ name: string;
8
+ envVar: string;
9
+ baseUrl: string | null;
10
+ }
11
+ /** Service definitions with their environment variables */
12
+ export declare const SERVICE_CONFIGS: ServiceConfig[];
13
+ export declare function initialize(): void;
14
+ export declare function setToken(jwt: string, refresh?: string, tenant?: string): void;
15
+ export declare function getToken(): string | null;
16
+ export declare function getRefreshToken(): string | null;
17
+ export declare function getTenantId(): string | null;
18
+ export declare function isAuthenticated(): boolean;
19
+ export declare function getClientForService(name: string): AxiosInstance | null;
20
+ export declare function getConfiguredServices(): ServiceConfig[];
21
+ export declare function getUserApiUrl(): string;
22
+ export interface AuthResult {
23
+ success: boolean;
24
+ token?: string;
25
+ refreshToken?: string;
26
+ email?: string;
27
+ name?: string;
28
+ tenantId?: string;
29
+ error?: string;
30
+ }
31
+ export declare function authenticate(email: string, password: string, tid: string): Promise<AuthResult>;
32
+ export declare function refreshAuth(rToken: string, tid: string): Promise<AuthResult>;
@@ -0,0 +1 @@
1
+ import axios from"axios";const DEFAULT_USER_API_URL="https://dotzerotech-user-api.dotzero.app";export const SERVICE_CONFIGS=[{name:"work-order",envVar:"WORK_ORDER_API_URL",baseUrl:null},{name:"spc",envVar:"SPC_API_URL",baseUrl:null},{name:"equipment",envVar:"EQUIPMENT_API_URL",baseUrl:null},{name:"device-topology",envVar:"DEVICE_TOPOLOGY_API_URL",baseUrl:null},{name:"oee",envVar:"OEE_API_URL",baseUrl:null}];let userApiUrl=DEFAULT_USER_API_URL,token=null,refreshTokenValue=null,tenantId=null;const apiClients=new Map;export function initialize(){userApiUrl=process.env.USER_API_URL||DEFAULT_USER_API_URL;for(const e of SERVICE_CONFIGS)e.baseUrl=process.env[e.envVar]||null}function createClient(e,r){return axios.create({baseURL:e,timeout:3e4,headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${r}`}})}export function setToken(e,r,t){token=e,r&&(refreshTokenValue=r),t&&(tenantId=t),apiClients.clear();for(const r of SERVICE_CONFIGS)r.baseUrl&&apiClients.set(r.name,createClient(r.baseUrl,e))}export function getToken(){return token}export function getRefreshToken(){return refreshTokenValue}export function getTenantId(){return tenantId}export function isAuthenticated(){return null!==token}export function getClientForService(e){return apiClients.get(e)||null}export function getConfiguredServices(){return SERVICE_CONFIGS.filter(e=>null!==e.baseUrl)}export function getUserApiUrl(){return userApiUrl}export async function authenticate(e,r,t){try{const n=`${userApiUrl}/v2/auth/login?tenantID=${encodeURIComponent(t)}`,o=await axios.post(n,{email:e,password:r},{timeout:1e4,headers:{"Content-Type":"application/json"}}),s=o.data.token;return s?(setToken(s,o.data.refresh_token,o.data.tenant_id||t),{success:!0,token:s,refreshToken:o.data.refresh_token,email:o.data.email,name:o.data.name,tenantId:o.data.tenant_id||t}):{success:!1,error:"No token received"}}catch(e){if(axios.isAxiosError(e)){const r=e;if(401===r.response?.status)return{success:!1,error:"Invalid email or password"};if(400===r.response?.status)return{success:!1,error:"Bad request. Verify tenant_id."};if(404===r.response?.status)return{success:!1,error:"Tenant not found."};const t=r.response?.data?.message||r.response?.data?.error;if(t)return{success:!1,error:t}}return{success:!1,error:`Authentication failed: ${e instanceof Error?e.message:String(e)}`}}}export async function refreshAuth(e,r){try{const t=`${userApiUrl}/v2/auth/token?tenantID=${encodeURIComponent(r)}`,n=await axios.post(t,{grant_type:"refresh_token",refresh_token:e},{timeout:1e4,headers:{"Content-Type":"application/json"}}),o="string"==typeof n.data?n.data:n.data.token;return o?(setToken(o,e,r),{success:!0,token:o,refreshToken:e,tenantId:r}):{success:!1,error:"No token received from refresh"}}catch(e){if(axios.isAxiosError(e)){const r=e,t=r.response?.data?.message||r.response?.data?.error;if(t)return{success:!1,error:t}}return{success:!1,error:`Token refresh failed: ${e instanceof Error?e.message:String(e)}`}}}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * DotZero Unified MCP Gateway
4
+ *
5
+ * A single MCP server that dynamically loads tools from all DotZero services.
6
+ * Starts with 6 tools, then loads service-specific tools on demand.
7
+ */
8
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{McpServer}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport}from"@modelcontextprotocol/sdk/server/stdio.js";import{StreamableHTTPServerTransport}from"@modelcontextprotocol/sdk/server/streamableHttp.js";import express from"express";import{initialize}from"./auth-state.js";import{authLoginTool,executeAuthLogin,setLoginCallback}from"./tools/auth-login.js";import{authStatusTool,executeAuthStatus}from"./tools/auth-status.js";import{authRefreshTool,executeAuthRefresh}from"./tools/auth-refresh.js";import{findToolsTool,executeFindTools}from"./tools/find-tools.js";import{listServicesTool,executeListServices}from"./tools/list-services.js";import{loadServiceTool,executeLoadService,setServerRef}from"./tools/load-service.js";const server=new McpServer({name:"dotzero-mcp-gateway",version:"1.0.0"});function reg(e,o,r){e.registerTool(o.name,{title:o.title,description:o.description,inputSchema:o.inputSchema,annotations:o.annotations},async e=>r(e))}async function runStdio(){try{initialize()}catch(e){console.error("ERROR:",e instanceof Error?e.message:String(e)),process.exit(1)}const e=new StdioServerTransport;await server.connect(e),console.error("DotZero MCP Gateway running via stdio")}async function runHTTP(){try{initialize()}catch(e){console.error("ERROR:",e instanceof Error?e.message:String(e)),process.exit(1)}const e=express();e.use(express.json()),e.post("/mcp",async(e,o)=>{const r=new StreamableHTTPServerTransport({sessionIdGenerator:void 0,enableJsonResponse:!0});o.on("close",()=>r.close()),await server.connect(r),await r.handleRequest(e,o,e.body)}),e.get("/health",(e,o)=>{o.json({status:"ok",name:"dotzero-mcp-gateway",version:"1.0.0"})});const o=parseInt(process.env.PORT||"3005");e.listen(o,()=>{console.error(`DotZero MCP Gateway running on http://localhost:${o}/mcp`)})}reg(server,authLoginTool,executeAuthLogin),reg(server,authStatusTool,executeAuthStatus),reg(server,authRefreshTool,executeAuthRefresh),reg(server,findToolsTool,executeFindTools),reg(server,listServicesTool,executeListServices),reg(server,loadServiceTool,executeLoadService),setServerRef(server),setLoginCallback(()=>{});const transport=process.env.TRANSPORT||"stdio";"http"===transport?runHTTP().catch(e=>{console.error("Server error:",e),process.exit(1)}):runStdio().catch(e=>{console.error("Server error:",e),process.exit(1)});
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Dynamic service loader.
3
+ * Loads service tool modules on demand and registers them with the MCP server.
4
+ */
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ export interface ServiceStatus {
7
+ name: string;
8
+ configured: boolean;
9
+ loaded: boolean;
10
+ toolCount: number;
11
+ baseUrl: string | null;
12
+ }
13
+ /** Get status of all services */
14
+ export declare function getServiceStatuses(): ServiceStatus[];
15
+ export declare function isServiceLoaded(name: string): boolean;
16
+ /**
17
+ * Load a service's tools into the MCP server.
18
+ * Uses a proxy pattern: tools are thin wrappers that forward requests to the service API.
19
+ */
20
+ export declare function loadService(server: McpServer, serviceName: string): {
21
+ success: boolean;
22
+ message: string;
23
+ toolCount: number;
24
+ };
@@ -0,0 +1 @@
1
+ import{getConfiguredServices,isAuthenticated,getClientForService}from"./auth-state.js";import{getToolsForService}from"./tool-catalog.js";import axios from"axios";import{z}from"zod";const loadedServices=new Set;export function getServiceStatuses(){const e=getConfiguredServices();return["work-order","spc","equipment","device-topology","oee"].map(t=>{const o=e.find(e=>e.name===t),r=getToolsForService(t);return{name:t,configured:void 0!==o,loaded:loadedServices.has(t),toolCount:r.length,baseUrl:o?.baseUrl||null}})}export function isServiceLoaded(e){return loadedServices.has(e)}function regProxy(e,t,o){e.registerTool(t.name,{title:t.title,description:t.description,inputSchema:t.inputSchema,annotations:t.annotations},async e=>o(e))}async function makeProxyRequest(e,t,o="GET",r,n){return(await e.request({method:o,url:t,data:r,params:n})).data}function handleProxyError(e){if(axios.isAxiosError(e)){const t=e;if(t.response){const e=t.response.status,o=t.response.data?.message||t.response.data?.error;return 401===e?"Error: Authentication failed. Use auth_login.":403===e?"Error: Permission denied.":404===e?"Error: Resource not found.":`Error: Status ${e}. ${o||""}`}if("ECONNREFUSED"===t.code)return"Error: Cannot connect to API."}return`Error: ${e instanceof Error?e.message:String(e)}`}export function loadService(e,t){if(loadedServices.has(t)){const e=getToolsForService(t);return{success:!0,message:`Service '${t}' is already loaded.`,toolCount:e.length}}if(!getConfiguredServices().find(e=>e.name===t))return{success:!1,message:`Service '${t}' is not configured. Set ${getEnvVarForService(t)} environment variable.`,toolCount:0};if(!isAuthenticated())return{success:!1,message:"Not authenticated. Use auth_login first.",toolCount:0};const o=getClientForService(t);if(!o)return{success:!1,message:`Cannot create API client for '${t}'.`,toolCount:0};const r=getToolsForService(t);for(const n of r){if("auth_login"===n.name||"auth_status"===n.name)continue;const r=z.object({params:z.record(z.unknown()).optional().describe("Parameters to pass to the tool (see find_tools for details)"),response_format:z.enum(["markdown","json"]).default("json").describe("Output format")}).strict();e.registerTool(n.name,{title:n.title,description:`[${t}] ${n.description}\n\nPass parameters as a JSON object in the 'params' field.`,inputSchema:r,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{const t=await makeProxyRequest(o,`/mcp/tool/${n.name}`,"POST",{params:e.params||{},response_format:e.response_format||"json"});return{content:[{type:"text",text:"string"==typeof t?t:JSON.stringify(t,null,2)}]}}catch(e){return{content:[{type:"text",text:handleProxyError(e)}],isError:!0}}})}const n=r.filter(e=>"auth_login"!==e.name&&"auth_status"!==e.name).length;return loadedServices.add(t),{success:!0,message:`Loaded ${n} tools for '${t}'.`,toolCount:n}}function getEnvVarForService(e){return{"work-order":"WORK_ORDER_API_URL",spc:"SPC_API_URL",equipment:"EQUIPMENT_API_URL","device-topology":"DEVICE_TOPOLOGY_API_URL",oee:"OEE_API_URL"}[e]||`${e.toUpperCase().replace(/-/g,"_")}_API_URL`}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Static catalog of all DotZero tools across all services.
3
+ * Used by find_tools for keyword search without needing to load service modules.
4
+ */
5
+ export interface CatalogEntry {
6
+ name: string;
7
+ title: string;
8
+ description: string;
9
+ keywords: string[];
10
+ service: string;
11
+ }
12
+ /** All tools across all services */
13
+ export declare const TOOL_CATALOG: CatalogEntry[];
14
+ /** Get unique service names */
15
+ export declare function getServiceNames(): string[];
16
+ /** Get tools for a specific service */
17
+ export declare function getToolsForService(service: string): CatalogEntry[];
18
+ /** Simple keyword search with scoring */
19
+ export declare function searchTools(query: string, limit?: number): Array<CatalogEntry & {
20
+ score: number;
21
+ }>;
@@ -0,0 +1 @@
1
+ export const TOOL_CATALOG=[{name:"auth_login",title:"Login",description:"Authenticate with email, password, and tenant_id",keywords:["auth","login","authenticate","token"],service:"work-order"},{name:"auth_status",title:"Auth Status",description:"Check authentication status",keywords:["auth","status","token"],service:"work-order"},{name:"workorder_list",title:"List Work Orders",description:"List work orders with filters for status, date ranges, rush orders",keywords:["workorder","list","filter","production","母工單"],service:"work-order"},{name:"workorder_get",title:"Get Work Order",description:"Get a specific work order by UUID or ID",keywords:["workorder","get","detail"],service:"work-order"},{name:"workorder_create",title:"Create Work Order",description:"Create a new work order",keywords:["workorder","create","new"],service:"work-order"},{name:"workorder_update",title:"Update Work Order",description:"Update an existing work order",keywords:["workorder","update","modify"],service:"work-order"},{name:"workorder_delete",title:"Delete Work Order",description:"Delete a work order",keywords:["workorder","delete","remove"],service:"work-order"},{name:"workorder_details",title:"Work Order Details",description:"Get work order with product info and operations",keywords:["workorder","detail","product","operation"],service:"work-order"},{name:"workorder_count",title:"Work Order Count",description:"Get total work order count",keywords:["workorder","count","total"],service:"work-order"},{name:"product_list",title:"List Products",description:"List products with filters",keywords:["product","list","material"],service:"work-order"},{name:"product_get",title:"Get Product",description:"Get product details by UUID",keywords:["product","get","detail"],service:"work-order"},{name:"product_create",title:"Create Product",description:"Create a new product",keywords:["product","create"],service:"work-order"},{name:"product_update",title:"Update Product",description:"Update a product",keywords:["product","update"],service:"work-order"},{name:"product_details",title:"Product Details",description:"Get product with routes and operations",keywords:["product","detail","route"],service:"work-order"},{name:"product_copy",title:"Copy Product",description:"Copy a product with its routes and operations",keywords:["product","copy","duplicate"],service:"work-order"},{name:"worker_list",title:"List Workers",description:"List workers with filters",keywords:["worker","employee","list"],service:"work-order"},{name:"worker_get",title:"Get Worker",description:"Get worker details",keywords:["worker","employee","get"],service:"work-order"},{name:"worker_create",title:"Create Worker",description:"Create a new worker",keywords:["worker","employee","create"],service:"work-order"},{name:"worker_update",title:"Update Worker",description:"Update a worker",keywords:["worker","employee","update"],service:"work-order"},{name:"worker_delete",title:"Delete Worker",description:"Delete a worker",keywords:["worker","employee","delete"],service:"work-order"},{name:"operation_history_list",title:"List Operation History",description:"List work order operation history (子工單)",keywords:["operation","history","子工單","sub","child"],service:"work-order"},{name:"operation_history_by_workorder",title:"Operation History by WO",description:"Get operations for a specific work order",keywords:["operation","history","workorder"],service:"work-order"},{name:"operation_history_get",title:"Get Operation History",description:"Get operation history details",keywords:["operation","history","get"],service:"work-order"},{name:"operation_history_create",title:"Create Operation History",description:"Create an operation history record",keywords:["operation","history","create"],service:"work-order"},{name:"operation_history_create_many",title:"Create Many Operations",description:"Batch create operation history records",keywords:["operation","history","batch","create"],service:"work-order"},{name:"operation_history_delete",title:"Delete Operation History",description:"Delete an operation history record",keywords:["operation","history","delete"],service:"work-order"},{name:"operation_history_timeline",title:"Operation Timeline",description:"Get operation timeline for a work order",keywords:["operation","timeline","history"],service:"work-order"},{name:"workorder_report",title:"Work Order Report",description:"Get operation report with filters",keywords:["report","analytics","production"],service:"work-order"},{name:"report_update",title:"Update Report",description:"Update report configuration",keywords:["report","update"],service:"work-order"},{name:"weekly_report",title:"Weekly Report",description:"Get weekly production report",keywords:["report","weekly","production"],service:"work-order"},{name:"analytics_operations",title:"Analytics Operations",description:"Get operation analytics data",keywords:["analytics","operation","data"],service:"work-order"},{name:"analytics_workorder_report",title:"Analytics WO Report",description:"Get work order analytics report",keywords:["analytics","workorder","report"],service:"work-order"},{name:"worker_efficiency_ranking",title:"Worker Efficiency",description:"Rank workers by efficiency metrics",keywords:["worker","efficiency","ranking","performance"],service:"work-order"},{name:"device_utilization_ranking",title:"Device Utilization",description:"Rank devices by utilization",keywords:["device","utilization","ranking","machine"],service:"work-order"},{name:"production_summary",title:"Production Summary",description:"Get production summary with good/defect counts",keywords:["production","summary","good","defect"],service:"work-order"},{name:"route_list",title:"List Routes",description:"List production routes",keywords:["route","process","list"],service:"work-order"},{name:"route_get",title:"Get Route",description:"Get route details",keywords:["route","get"],service:"work-order"},{name:"route_create",title:"Create Route",description:"Create a production route",keywords:["route","create"],service:"work-order"},{name:"route_update",title:"Update Route",description:"Update a route",keywords:["route","update"],service:"work-order"},{name:"route_delete",title:"Delete Route",description:"Delete a route",keywords:["route","delete"],service:"work-order"},{name:"route_by_product",title:"Routes by Product",description:"Get routes for a product",keywords:["route","product"],service:"work-order"},{name:"route_copy",title:"Copy Route",description:"Copy a route",keywords:["route","copy","duplicate"],service:"work-order"},{name:"operation_list",title:"List Operations",description:"List operation definitions",keywords:["operation","process","list"],service:"work-order"},{name:"operation_get",title:"Get Operation",description:"Get operation details",keywords:["operation","get"],service:"work-order"},{name:"operation_create",title:"Create Operation",description:"Create an operation definition",keywords:["operation","create"],service:"work-order"},{name:"operation_update",title:"Update Operation",description:"Update an operation",keywords:["operation","update"],service:"work-order"},{name:"operation_delete",title:"Delete Operation",description:"Delete an operation",keywords:["operation","delete"],service:"work-order"},{name:"route_operation_list",title:"List Route Operations",description:"List operations in a route",keywords:["route","operation","list","sequence"],service:"work-order"},{name:"route_operation_get",title:"Get Route Operation",description:"Get route operation details",keywords:["route","operation","get"],service:"work-order"},{name:"route_operation_create",title:"Create Route Operation",description:"Add operation to a route",keywords:["route","operation","create","add"],service:"work-order"},{name:"route_operation_update",title:"Update Route Operation",description:"Update a route operation",keywords:["route","operation","update"],service:"work-order"},{name:"route_operation_delete",title:"Delete Route Operation",description:"Remove operation from route",keywords:["route","operation","delete","remove"],service:"work-order"},{name:"route_operation_by_route",title:"Operations by Route",description:"Get all operations for a route",keywords:["route","operation","by"],service:"work-order"},{name:"device_list",title:"List Devices",description:"List manufacturing devices/machines",keywords:["device","machine","list"],service:"work-order"},{name:"device_get",title:"Get Device",description:"Get device details",keywords:["device","machine","get"],service:"work-order"},{name:"device_create",title:"Create Device",description:"Create a device",keywords:["device","machine","create"],service:"work-order"},{name:"device_update",title:"Update Device",description:"Update a device",keywords:["device","machine","update"],service:"work-order"},{name:"device_delete",title:"Delete Device",description:"Delete a device",keywords:["device","machine","delete"],service:"work-order"},{name:"defect_reason_list",title:"List Defect Reasons",description:"List defect reason codes",keywords:["defect","reason","quality","list"],service:"work-order"},{name:"defect_reason_create",title:"Create Defect Reason",description:"Create a defect reason",keywords:["defect","reason","create"],service:"work-order"},{name:"defect_reason_update",title:"Update Defect Reason",description:"Update a defect reason",keywords:["defect","reason","update"],service:"work-order"},{name:"defect_reason_delete",title:"Delete Defect Reason",description:"Delete a defect reason",keywords:["defect","reason","delete"],service:"work-order"},{name:"defect_reason_category_list",title:"List Defect Categories",description:"List defect reason categories",keywords:["defect","category","list"],service:"work-order"},{name:"defect_reason_category_get",title:"Get Defect Category",description:"Get defect category details",keywords:["defect","category","get"],service:"work-order"},{name:"defect_reason_category_create",title:"Create Defect Category",description:"Create a defect category",keywords:["defect","category","create"],service:"work-order"},{name:"defect_reason_category_update",title:"Update Defect Category",description:"Update a defect category",keywords:["defect","category","update"],service:"work-order"},{name:"station_list",title:"List Stations",description:"List production stations",keywords:["station","workstation","list"],service:"work-order"},{name:"station_get",title:"Get Station",description:"Get station details",keywords:["station","get"],service:"work-order"},{name:"station_create",title:"Create Station",description:"Create a station",keywords:["station","create"],service:"work-order"},{name:"station_update",title:"Update Station",description:"Update a station",keywords:["station","update"],service:"work-order"},{name:"station_delete",title:"Delete Station",description:"Delete a station",keywords:["station","delete"],service:"work-order"},{name:"station_device_list",title:"Station Devices",description:"List devices at a station",keywords:["station","device","machine"],service:"work-order"},{name:"abnormal_history_list",title:"List Abnormal History",description:"List abnormal/exception history",keywords:["abnormal","exception","history","list"],service:"work-order"},{name:"abnormal_history_get",title:"Get Abnormal History",description:"Get abnormal history details",keywords:["abnormal","exception","get"],service:"work-order"},{name:"abnormal_history_create",title:"Create Abnormal History",description:"Log an abnormal event",keywords:["abnormal","exception","create","log"],service:"work-order"},{name:"abnormal_history_update",title:"Update Abnormal History",description:"Update abnormal history",keywords:["abnormal","exception","update"],service:"work-order"},{name:"abnormal_history_by_workorder",title:"Abnormal by WO",description:"Get abnormal history for a work order",keywords:["abnormal","exception","workorder"],service:"work-order"},{name:"abnormal_category_list",title:"List Abnormal Categories",description:"List abnormal categories",keywords:["abnormal","category","list"],service:"work-order"},{name:"abnormal_category_create",title:"Create Abnormal Category",description:"Create abnormal category",keywords:["abnormal","category","create"],service:"work-order"},{name:"abnormal_state_list",title:"List Abnormal States",description:"List abnormal states",keywords:["abnormal","state","list"],service:"work-order"},{name:"abnormal_state_create",title:"Create Abnormal State",description:"Create abnormal state",keywords:["abnormal","state","create"],service:"work-order"},{name:"op_product_bom_list",title:"List Op Product BOM",description:"List operation product BOM entries",keywords:["bom","material","list","bill"],service:"work-order"},{name:"op_product_bom_create",title:"Create Op Product BOM",description:"Create BOM entry",keywords:["bom","material","create"],service:"work-order"},{name:"op_product_bom_update",title:"Update Op Product BOM",description:"Update BOM entry",keywords:["bom","material","update"],service:"work-order"},{name:"op_product_bom_delete",title:"Delete Op Product BOM",description:"Delete BOM entry",keywords:["bom","material","delete"],service:"work-order"},{name:"warehouse_list",title:"List Warehouses",description:"List warehouses",keywords:["warehouse","inventory","list"],service:"work-order"},{name:"warehouse_get",title:"Get Warehouse",description:"Get warehouse details",keywords:["warehouse","get"],service:"work-order"},{name:"warehouse_create",title:"Create Warehouse",description:"Create a warehouse",keywords:["warehouse","create"],service:"work-order"},{name:"warehouse_update",title:"Update Warehouse",description:"Update a warehouse",keywords:["warehouse","update"],service:"work-order"},{name:"warehouse_storage_list",title:"List Warehouse Storage",description:"List warehouse storage locations",keywords:["warehouse","storage","location","list"],service:"work-order"},{name:"warehouse_storage_get",title:"Get Warehouse Storage",description:"Get storage location details",keywords:["warehouse","storage","get"],service:"work-order"},{name:"warehouse_storage_create",title:"Create Warehouse Storage",description:"Create storage location",keywords:["warehouse","storage","create"],service:"work-order"},{name:"warehouse_storage_update",title:"Update Warehouse Storage",description:"Update storage location",keywords:["warehouse","storage","update"],service:"work-order"},{name:"product_storage_list",title:"List Product Storage",description:"List product storage records",keywords:["product","storage","inventory","list"],service:"work-order"},{name:"product_storage_get",title:"Get Product Storage",description:"Get product storage details",keywords:["product","storage","get"],service:"work-order"},{name:"product_storage_by_product",title:"Storage by Product",description:"Get storage for a product",keywords:["product","storage","by"],service:"work-order"},{name:"wms_check_inventory",title:"Check Inventory",description:"Check product inventory levels",keywords:["wms","inventory","check","stock"],service:"work-order"},{name:"wms_query_product_storage",title:"Query Product Storage",description:"Query WMS product storage",keywords:["wms","product","storage","query"],service:"work-order"},{name:"wms_query_storage_history",title:"Storage History",description:"Query storage transaction history",keywords:["wms","storage","history","transaction"],service:"work-order"},{name:"wms_minimal_stock_count",title:"Minimal Stock Count",description:"Get products below minimum stock",keywords:["wms","stock","minimal","alert","reorder"],service:"work-order"},{name:"spc_product_manufacture_list",title:"SPC Manufacture Products",description:"List SPC products for manufacturing",keywords:["spc","product","manufacture","list"],service:"spc"},{name:"spc_product_stock_list",title:"SPC Stock Products",description:"List SPC products for stock inspection",keywords:["spc","product","stock","list"],service:"spc"},{name:"spc_history_list",title:"SPC History List",description:"List SPC measurement history",keywords:["spc","history","measurement","list"],service:"spc"},{name:"spc_history_batch_upsert",title:"SPC History Batch Upsert",description:"Batch upsert SPC history records",keywords:["spc","history","batch","upsert"],service:"spc"},{name:"spc_history_batch_by_group",title:"SPC History by Group",description:"Get SPC history by group",keywords:["spc","history","group"],service:"spc"},{name:"spc_history_delete_by_group",title:"SPC History Delete Group",description:"Delete SPC history by group",keywords:["spc","history","group","delete"],service:"spc"},{name:"spc_config_parent_get",title:"Get SPC Config Parent",description:"Get SPC config parent with measure point configs",keywords:["spc","config","parent","get"],service:"spc"},{name:"spc_config_parent_create",title:"Create SPC Config Parent",description:"Create SPC config parent",keywords:["spc","config","parent","create"],service:"spc"},{name:"spc_config_parent_update",title:"Update SPC Config Parent",description:"Update SPC config parent",keywords:["spc","config","parent","update"],service:"spc"},{name:"spc_config_parent_attachment_add",title:"Add Config Attachment",description:"Add attachment to SPC config parent",keywords:["spc","config","attachment","add","upload"],service:"spc"},{name:"spc_config_parent_attachment_delete",title:"Delete Config Attachment",description:"Delete attachment from SPC config parent",keywords:["spc","config","attachment","delete"],service:"spc"},{name:"spc_measure_config_list",title:"List Measure Configs",description:"List SPC measure point configurations",keywords:["spc","measure","config","list","tolerance"],service:"spc"},{name:"spc_measure_config_get",title:"Get Measure Config",description:"Get measure point config details",keywords:["spc","measure","config","get"],service:"spc"},{name:"spc_measure_config_create",title:"Create Measure Config",description:"Create a measure point config (USL/LSL/std value)",keywords:["spc","measure","config","create","usl","lsl"],service:"spc"},{name:"spc_measure_config_update",title:"Update Measure Config",description:"Update a measure point config",keywords:["spc","measure","config","update"],service:"spc"},{name:"spc_measure_config_delete",title:"Delete Measure Config",description:"Delete a measure point config",keywords:["spc","measure","config","delete"],service:"spc"},{name:"spc_measure_config_attachment_add",title:"Add Measure Attachment",description:"Add attachment to measure config",keywords:["spc","measure","attachment","upload"],service:"spc"},{name:"spc_measure_config_attachment_delete",title:"Delete Measure Attachment",description:"Delete attachment from measure config",keywords:["spc","measure","attachment","delete"],service:"spc"},{name:"spc_measure_config_modes",title:"Measure Config Modes",description:"List tolerance modes",keywords:["spc","measure","mode","tolerance"],service:"spc"},{name:"spc_measure_config_categories",title:"Measure Config Categories",description:"List measure categories",keywords:["spc","measure","category"],service:"spc"},{name:"spc_measure_history_create",title:"Create Measurement",description:"Create a measurement record",keywords:["spc","measure","history","create"],service:"spc"},{name:"spc_measure_history_upsert",title:"Upsert Measurement",description:"Upsert a measurement record",keywords:["spc","measure","history","upsert"],service:"spc"},{name:"spc_measure_history_update",title:"Update Measurement",description:"Update a measurement record",keywords:["spc","measure","history","update"],service:"spc"},{name:"spc_measure_history_delete",title:"Delete Measurement",description:"Delete a measurement",keywords:["spc","measure","history","delete"],service:"spc"},{name:"spc_measure_history_batch_upsert",title:"Batch Upsert Measurements",description:"Batch upsert measurements",keywords:["spc","measure","history","batch","upsert"],service:"spc"},{name:"spc_measure_history_batch_delete",title:"Batch Delete Measurements",description:"Batch delete measurements",keywords:["spc","measure","history","batch","delete"],service:"spc"},{name:"spc_measure_history_manufacture",title:"Manufacture Measurements",description:"Get manufacture measurement history",keywords:["spc","measure","manufacture","history"],service:"spc"},{name:"spc_measure_history_stock",title:"Stock Measurements",description:"Get stock measurement history",keywords:["spc","measure","stock","history"],service:"spc"},{name:"spc_measure_history_count",title:"Measurement Count",description:"Get measurement history count",keywords:["spc","measure","count"],service:"spc"},{name:"spc_measure_history_filter_list",title:"Filter Manufacture History",description:"Filter manufacture measurement history",keywords:["spc","measure","filter","manufacture"],service:"spc"},{name:"spc_measure_history_filter_list_stock",title:"Filter Stock History",description:"Filter stock measurement history",keywords:["spc","measure","filter","stock"],service:"spc"},{name:"spc_instrument_list",title:"List Instruments",description:"List SPC instruments",keywords:["spc","instrument","calibration","list"],service:"spc"},{name:"spc_instrument_create",title:"Create Instrument",description:"Create an SPC instrument",keywords:["spc","instrument","create"],service:"spc"},{name:"spc_instrument_update",title:"Update Instrument",description:"Update an instrument",keywords:["spc","instrument","update"],service:"spc"},{name:"spc_instrument_delete",title:"Delete Instrument",description:"Delete an instrument",keywords:["spc","instrument","delete"],service:"spc"},{name:"spc_instrument_batch_delete",title:"Batch Delete Instruments",description:"Batch delete instruments",keywords:["spc","instrument","batch","delete"],service:"spc"},{name:"spc_rule_list",title:"List SPC Rules",description:"List Nelson rules",keywords:["spc","rule","nelson"],service:"spc"},{name:"spc_dashboard_list",title:"List Dashboards",description:"List SPC dashboards",keywords:["spc","dashboard","chart","list"],service:"spc"},{name:"spc_dashboard_create",title:"Create Dashboard",description:"Create SPC stock dashboard",keywords:["spc","dashboard","chart","create","stock"],service:"spc"},{name:"spc_dashboard_update",title:"Update Dashboard",description:"Update SPC stock dashboard",keywords:["spc","dashboard","chart","update","stock"],service:"spc"},{name:"spc_dashboard_delete",title:"Delete Dashboard",description:"Delete SPC dashboard",keywords:["spc","dashboard","delete"],service:"spc"},{name:"spc_dashboard_manufacture_create",title:"Create Mfg Dashboard",description:"Create SPC manufacture dashboard",keywords:["spc","dashboard","manufacture","create","control chart"],service:"spc"},{name:"spc_dashboard_manufacture_update",title:"Update Mfg Dashboard",description:"Update SPC manufacture dashboard",keywords:["spc","dashboard","manufacture","update","control chart"],service:"spc"},{name:"spc_statistics_nelson",title:"Nelson Analysis",description:"Run Nelson rules analysis on measurement data",keywords:["spc","statistics","nelson","rule","analysis","control chart"],service:"spc"},{name:"spc_statistics_capability",title:"Process Capability",description:"Calculate Cp, Cpk, Pp, Ppk capability indices",keywords:["spc","statistics","capability","cpk","cp","ppk"],service:"spc"},{name:"spc_statistics_capability_by_point",title:"Capability by Point",description:"Get capability per measure point",keywords:["spc","statistics","capability","point"],service:"spc"},{name:"spc_statistics_calculate_result",title:"Calculate Statistic",description:"Calculate SPC statistic metric",keywords:["spc","statistics","calculate","metric"],service:"spc"},{name:"equip_alarm_list",title:"Equipment Alarms",description:"List equipment alarms with time range",keywords:["equipment","alarm","alert","list"],service:"equipment"},{name:"equip_idle_list",title:"Equipment Idle",description:"List equipment idle periods",keywords:["equipment","idle","downtime","list"],service:"equipment"},{name:"equip_machine_status_history",title:"Machine Status History",description:"Get machine status history",keywords:["equipment","machine","status","history"],service:"equipment"},{name:"equip_machine_status_part_counts",title:"Part Counts",description:"Get machine part counts",keywords:["equipment","machine","part","count","output"],service:"equipment"},{name:"equip_machine_status_part_counts_batch",title:"Part Counts Batch",description:"Get part counts for multiple devices",keywords:["equipment","machine","part","count","batch"],service:"equipment"},{name:"equip_machine_status_realtime",title:"Realtime Status",description:"Get machine realtime status",keywords:["equipment","machine","realtime","status","live"],service:"equipment"},{name:"equip_machine_status_realtime_batch",title:"Realtime Batch",description:"Get realtime status for multiple devices",keywords:["equipment","machine","realtime","batch"],service:"equipment"},{name:"equip_off_time_list",title:"Off Time",description:"List equipment off-time periods",keywords:["equipment","off","time","shutdown","list"],service:"equipment"},{name:"equip_state_counts_factory",title:"Factory State Counts",description:"Get equipment state counts for factory",keywords:["equipment","state","count","factory"],service:"equipment"},{name:"equip_state_counts_line",title:"Line State Counts",description:"Get equipment state counts for line",keywords:["equipment","state","count","line"],service:"equipment"},{name:"topo_group_list",title:"List Groups",description:"List device topology groups",keywords:["topology","group","list"],service:"device-topology"},{name:"topo_group_get",title:"Get Group",description:"Get topology group details",keywords:["topology","group","get"],service:"device-topology"},{name:"topo_group_create",title:"Create Group",description:"Create topology group",keywords:["topology","group","create"],service:"device-topology"},{name:"topo_group_update",title:"Update Group",description:"Update topology group",keywords:["topology","group","update"],service:"device-topology"},{name:"topo_group_delete",title:"Delete Group",description:"Delete topology group",keywords:["topology","group","delete"],service:"device-topology"},{name:"topo_factory_list",title:"List Factories",description:"List factories",keywords:["topology","factory","plant","list"],service:"device-topology"},{name:"topo_factory_get",title:"Get Factory",description:"Get factory details",keywords:["topology","factory","get"],service:"device-topology"},{name:"topo_factory_create",title:"Create Factory",description:"Create factory",keywords:["topology","factory","create"],service:"device-topology"},{name:"topo_factory_update",title:"Update Factory",description:"Update factory",keywords:["topology","factory","update"],service:"device-topology"},{name:"topo_factory_delete",title:"Delete Factory",description:"Delete factory",keywords:["topology","factory","delete"],service:"device-topology"},{name:"topo_line_list",title:"List Lines",description:"List production lines",keywords:["topology","line","production","list"],service:"device-topology"},{name:"topo_line_get",title:"Get Line",description:"Get line details",keywords:["topology","line","get"],service:"device-topology"},{name:"topo_line_create",title:"Create Line",description:"Create production line",keywords:["topology","line","create"],service:"device-topology"},{name:"topo_line_update",title:"Update Line",description:"Update line",keywords:["topology","line","update"],service:"device-topology"},{name:"topo_line_delete",title:"Delete Line",description:"Delete line",keywords:["topology","line","delete"],service:"device-topology"},{name:"topo_device_list",title:"List Topo Devices",description:"List devices in topology",keywords:["topology","device","machine","list"],service:"device-topology"},{name:"topo_device_get",title:"Get Topo Device",description:"Get topology device details",keywords:["topology","device","get"],service:"device-topology"},{name:"topo_device_create",title:"Create Topo Device",description:"Create device in topology",keywords:["topology","device","create"],service:"device-topology"},{name:"topo_device_update",title:"Update Topo Device",description:"Update topology device",keywords:["topology","device","update"],service:"device-topology"},{name:"topo_device_delete",title:"Delete Topo Device",description:"Delete topology device",keywords:["topology","device","delete"],service:"device-topology"},{name:"topo_plant_floor_get",title:"Get Plant Floor",description:"Get plant floor layout",keywords:["topology","plant","floor","layout","get"],service:"device-topology"},{name:"topo_plant_floor_create",title:"Create Plant Floor",description:"Create plant floor",keywords:["topology","plant","floor","create"],service:"device-topology"},{name:"topo_plant_floor_update",title:"Update Plant Floor",description:"Update plant floor",keywords:["topology","plant","floor","update"],service:"device-topology"},{name:"topo_plant_floor_delete",title:"Delete Plant Floor",description:"Delete plant floor",keywords:["topology","plant","floor","delete"],service:"device-topology"},{name:"topo_alarm_list",title:"List Topo Alarms",description:"List topology alarm definitions",keywords:["topology","alarm","list"],service:"device-topology"},{name:"topo_alarm_get",title:"Get Topo Alarm",description:"Get alarm details",keywords:["topology","alarm","get"],service:"device-topology"},{name:"topo_alarm_create",title:"Create Topo Alarm",description:"Create alarm definition",keywords:["topology","alarm","create"],service:"device-topology"},{name:"topo_alarm_update",title:"Update Topo Alarm",description:"Update alarm",keywords:["topology","alarm","update"],service:"device-topology"},{name:"topo_alarm_delete",title:"Delete Topo Alarm",description:"Delete alarm",keywords:["topology","alarm","delete"],service:"device-topology"},{name:"topo_alarm_code_list",title:"List Alarm Codes",description:"List alarm codes",keywords:["topology","alarm","code","list"],service:"device-topology"},{name:"topo_alarm_code_get",title:"Get Alarm Code",description:"Get alarm code details",keywords:["topology","alarm","code","get"],service:"device-topology"},{name:"topo_alarm_code_create",title:"Create Alarm Code",description:"Create alarm code",keywords:["topology","alarm","code","create"],service:"device-topology"},{name:"topo_alarm_code_update",title:"Update Alarm Code",description:"Update alarm code",keywords:["topology","alarm","code","update"],service:"device-topology"},{name:"topo_alarm_code_delete",title:"Delete Alarm Code",description:"Delete alarm code",keywords:["topology","alarm","code","delete"],service:"device-topology"},{name:"topo_alarm_code_batch",title:"Batch Alarm Codes",description:"Batch create/update alarm codes",keywords:["topology","alarm","code","batch"],service:"device-topology"},{name:"topo_topology_count",title:"Topology Count",description:"Get counts of topology entities",keywords:["topology","count","summary"],service:"device-topology"},{name:"topo_topology_all",title:"Topology All",description:"Get complete topology tree",keywords:["topology","tree","all","hierarchy"],service:"device-topology"},{name:"oee_availability_device",title:"Device Availability",description:"Get availability for a single device",keywords:["oee","availability","device","uptime"],service:"oee"},{name:"oee_availability_devices",title:"Multi-Device Availability",description:"Get availability for multiple devices",keywords:["oee","availability","devices","batch"],service:"oee"},{name:"oee_availability_line",title:"Line Availability",description:"Get availability for a production line",keywords:["oee","availability","line"],service:"oee"},{name:"oee_availability_factory",title:"Factory Availability",description:"Get availability for a factory",keywords:["oee","availability","factory"],service:"oee"},{name:"oee_quality_device",title:"Device Quality",description:"Get quality rate for a device",keywords:["oee","quality","device","yield"],service:"oee"},{name:"oee_quality_devices",title:"Multi-Device Quality",description:"Get quality for multiple devices",keywords:["oee","quality","devices","batch"],service:"oee"},{name:"oee_quality_line",title:"Line Quality",description:"Get quality for a line",keywords:["oee","quality","line"],service:"oee"},{name:"oee_quality_factory",title:"Factory Quality",description:"Get quality for a factory",keywords:["oee","quality","factory"],service:"oee"},{name:"oee_performance_device",title:"Device Performance",description:"Get performance rate for a device",keywords:["oee","performance","device","speed"],service:"oee"},{name:"oee_performance_devices",title:"Multi-Device Performance",description:"Get performance for multiple devices",keywords:["oee","performance","devices","batch"],service:"oee"},{name:"oee_performance_line",title:"Line Performance",description:"Get performance for a line",keywords:["oee","performance","line"],service:"oee"},{name:"oee_performance_factory",title:"Factory Performance",description:"Get performance for a factory",keywords:["oee","performance","factory"],service:"oee"},{name:"oee_performance_device_range",title:"Device Perf Range",description:"Get performance over date range",keywords:["oee","performance","device","range","trend"],service:"oee"},{name:"oee_device",title:"Device OEE",description:"Get OEE for a device (availability × quality × performance)",keywords:["oee","device","overall","effectiveness"],service:"oee"},{name:"oee_devices",title:"Multi-Device OEE",description:"Get OEE for multiple devices",keywords:["oee","devices","batch"],service:"oee"},{name:"oee_line",title:"Line OEE",description:"Get OEE for a line",keywords:["oee","line","overall"],service:"oee"},{name:"oee_factory",title:"Factory OEE",description:"Get OEE for a factory",keywords:["oee","factory","overall"],service:"oee"},{name:"oee_device_status",title:"Device Status",description:"Get current device status (run/idle/off)",keywords:["oee","device","status","realtime"],service:"oee"},{name:"oee_alarm_history",title:"OEE Alarm History",description:"Get alarm history with downtime data",keywords:["oee","alarm","history","downtime"],service:"oee"}];export function getServiceNames(){return[...new Set(TOOL_CATALOG.map(e=>e.service))]}export function getToolsForService(e){return TOOL_CATALOG.filter(t=>t.service===e)}export function searchTools(e,t=10){const r=e.toLowerCase().split(/\s+/).filter(e=>e.length>1);if(0===r.length)return[];return TOOL_CATALOG.map(e=>{let t=0;const o=e.name.toLowerCase(),i=e.title.toLowerCase(),s=e.description.toLowerCase(),a=e.keywords.join(" ").toLowerCase();for(const e of r)o.includes(e)&&(t+=3),i.includes(e)&&(t+=2),s.includes(e)&&(t+=1),a.includes(e)&&(t+=2);return{...e,score:t}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,t)}
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ export declare const AuthLoginSchema: z.ZodObject<{
3
+ email: z.ZodString;
4
+ password: z.ZodString;
5
+ tenant_id: z.ZodString;
6
+ }, "strict", z.ZodTypeAny, {
7
+ email: string;
8
+ password: string;
9
+ tenant_id: string;
10
+ }, {
11
+ email: string;
12
+ password: string;
13
+ tenant_id: string;
14
+ }>;
15
+ export type AuthLoginInput = z.infer<typeof AuthLoginSchema>;
16
+ export declare const authLoginTool: {
17
+ name: string;
18
+ title: string;
19
+ description: string;
20
+ inputSchema: z.ZodObject<{
21
+ email: z.ZodString;
22
+ password: z.ZodString;
23
+ tenant_id: z.ZodString;
24
+ }, "strict", z.ZodTypeAny, {
25
+ email: string;
26
+ password: string;
27
+ tenant_id: string;
28
+ }, {
29
+ email: string;
30
+ password: string;
31
+ tenant_id: string;
32
+ }>;
33
+ annotations: {
34
+ readOnlyHint: boolean;
35
+ destructiveHint: boolean;
36
+ idempotentHint: boolean;
37
+ openWorldHint: boolean;
38
+ };
39
+ };
40
+ export declare function setLoginCallback(cb: () => void): void;
41
+ export declare function executeAuthLogin(params: AuthLoginInput): Promise<{
42
+ content: {
43
+ type: "text";
44
+ text: string;
45
+ }[];
46
+ isError?: undefined;
47
+ } | {
48
+ content: {
49
+ type: "text";
50
+ text: string;
51
+ }[];
52
+ isError: boolean;
53
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{authenticate}from"../auth-state.js";export const AuthLoginSchema=z.object({email:z.string().email().describe("User email address"),password:z.string().min(1).describe("User password"),tenant_id:z.string().min(1).describe("Tenant ID for authentication (ask user if not known)")}).strict();export const authLoginTool={name:"auth_login",title:"Login",description:"Authenticate with DotZero to access all services.\n\nOne login authenticates across ALL DotZero APIs (Work Order, SPC, Equipment, Device Topology, OEE).\n\nIMPORTANT: You must ask the user for their tenant_id if not known.\n\nReturns: Authentication status and available services.",inputSchema:AuthLoginSchema,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}};let onLoginSuccess=null;export function setLoginCallback(t){onLoginSuccess=t}export async function executeAuthLogin(t){const e=await authenticate(t.email,t.password,t.tenant_id);if(e.success){onLoginSuccess?.();return{content:[{type:"text",text:["# Authentication Successful","",`- **Email**: ${e.email||t.email}`,e.name?`- **Name**: ${e.name}`:"",`- **Tenant**: ${e.tenantId||t.tenant_id}`,"","Use `list_services` to see available services, then `load_service` to load tools."].filter(Boolean).join("\n")}]}}return{content:[{type:"text",text:`Authentication failed: ${e.error}`}],isError:!0}}
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ export declare const AuthRefreshSchema: z.ZodObject<{
3
+ refresh_token: z.ZodOptional<z.ZodString>;
4
+ tenant_id: z.ZodOptional<z.ZodString>;
5
+ }, "strict", z.ZodTypeAny, {
6
+ refresh_token?: string | undefined;
7
+ tenant_id?: string | undefined;
8
+ }, {
9
+ refresh_token?: string | undefined;
10
+ tenant_id?: string | undefined;
11
+ }>;
12
+ export type AuthRefreshInput = z.infer<typeof AuthRefreshSchema>;
13
+ export declare const authRefreshTool: {
14
+ name: string;
15
+ title: string;
16
+ description: string;
17
+ inputSchema: z.ZodObject<{
18
+ refresh_token: z.ZodOptional<z.ZodString>;
19
+ tenant_id: z.ZodOptional<z.ZodString>;
20
+ }, "strict", z.ZodTypeAny, {
21
+ refresh_token?: string | undefined;
22
+ tenant_id?: string | undefined;
23
+ }, {
24
+ refresh_token?: string | undefined;
25
+ tenant_id?: string | undefined;
26
+ }>;
27
+ annotations: {
28
+ readOnlyHint: boolean;
29
+ destructiveHint: boolean;
30
+ idempotentHint: boolean;
31
+ openWorldHint: boolean;
32
+ };
33
+ };
34
+ export declare function executeAuthRefresh(params: AuthRefreshInput): Promise<{
35
+ content: {
36
+ type: "text";
37
+ text: string;
38
+ }[];
39
+ isError: boolean;
40
+ } | {
41
+ content: {
42
+ type: "text";
43
+ text: string;
44
+ }[];
45
+ isError?: undefined;
46
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{refreshAuth,getRefreshToken,getTenantId}from"../auth-state.js";export const AuthRefreshSchema=z.object({refresh_token:z.string().optional().describe("Refresh token (uses stored token if omitted)"),tenant_id:z.string().optional().describe("Tenant ID (uses stored tenant if omitted)")}).strict();export const authRefreshTool={name:"auth_refresh",title:"Refresh Token",description:"Refresh an expired JWT token.\n\nUses stored refresh token and tenant ID by default.\n\nReturns: New token status.",inputSchema:AuthRefreshSchema,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}};export async function executeAuthRefresh(e){const t=e.refresh_token||getRefreshToken(),n=e.tenant_id||getTenantId();if(!t)return{content:[{type:"text",text:"Error: No refresh token available. Use auth_login first."}],isError:!0};if(!n)return{content:[{type:"text",text:"Error: No tenant_id available. Provide tenant_id or use auth_login first."}],isError:!0};const r=await refreshAuth(t,n);return r.success?{content:[{type:"text",text:"# Token Refreshed\n\nAuthentication token has been refreshed successfully."}]}:{content:[{type:"text",text:`Token refresh failed: ${r.error}`}],isError:!0}}
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ export declare const AuthStatusSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
3
+ export declare const authStatusTool: {
4
+ name: string;
5
+ title: string;
6
+ description: string;
7
+ inputSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
8
+ annotations: {
9
+ readOnlyHint: boolean;
10
+ destructiveHint: boolean;
11
+ idempotentHint: boolean;
12
+ openWorldHint: boolean;
13
+ };
14
+ };
15
+ export declare function executeAuthStatus(): Promise<{
16
+ content: {
17
+ type: "text";
18
+ text: string;
19
+ }[];
20
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{isAuthenticated,getUserApiUrl}from"../auth-state.js";import{getServiceStatuses}from"../service-loader.js";export const AuthStatusSchema=z.object({}).strict();export const authStatusTool={name:"auth_status",title:"Auth Status",description:"Check authentication status and available services.\n\nReturns: Auth status, configured API URLs, and service load status.",inputSchema:AuthStatusSchema,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};export async function executeAuthStatus(){const t=isAuthenticated(),e=getServiceStatuses(),s=["# DotZero Gateway Status","","- **Authenticated**: "+(t?"Yes":"No"),`- **User API**: ${getUserApiUrl()}`,"","## Services","","| Service | Configured | Loaded | Tools |","|---------|-----------|--------|-------|"];for(const t of e)s.push(`| ${t.name} | ${t.configured?"Yes":"No"} | ${t.loaded?"Yes":"No"} | ${t.toolCount} |`);return t||s.push("","*Use `auth_login` to authenticate.*"),{content:[{type:"text",text:s.join("\n")}]}}
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ export declare const FindToolsSchema: z.ZodObject<{
3
+ query: z.ZodString;
4
+ limit: z.ZodDefault<z.ZodNumber>;
5
+ }, "strict", z.ZodTypeAny, {
6
+ query: string;
7
+ limit: number;
8
+ }, {
9
+ query: string;
10
+ limit?: number | undefined;
11
+ }>;
12
+ export type FindToolsInput = z.infer<typeof FindToolsSchema>;
13
+ export declare const findToolsTool: {
14
+ name: string;
15
+ title: string;
16
+ description: string;
17
+ inputSchema: z.ZodObject<{
18
+ query: z.ZodString;
19
+ limit: z.ZodDefault<z.ZodNumber>;
20
+ }, "strict", z.ZodTypeAny, {
21
+ query: string;
22
+ limit: number;
23
+ }, {
24
+ query: string;
25
+ limit?: number | undefined;
26
+ }>;
27
+ annotations: {
28
+ readOnlyHint: boolean;
29
+ destructiveHint: boolean;
30
+ idempotentHint: boolean;
31
+ openWorldHint: boolean;
32
+ };
33
+ };
34
+ export declare function executeFindTools(params: FindToolsInput): Promise<{
35
+ content: {
36
+ type: "text";
37
+ text: string;
38
+ }[];
39
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{searchTools}from"../tool-catalog.js";import{isServiceLoaded}from"../service-loader.js";export const FindToolsSchema=z.object({query:z.string().min(1).describe("Search query (keywords describing what you want to do)"),limit:z.number().int().min(1).max(50).default(10).describe("Maximum results to return")}).strict();export const findToolsTool={name:"find_tools",title:"Find Tools",description:'Search for DotZero tools by keyword or intent.\n\nExamples:\n- "SPC control chart" → finds SPC dashboard and statistics tools\n- "OEE availability" → finds OEE availability tools\n- "work order report" → finds work order reporting tools\n- "device topology factory" → finds factory management tools\n\nReturns: Matching tools grouped by service with load status.',inputSchema:FindToolsSchema,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};export async function executeFindTools(o){const t=searchTools(o.query,o.limit);if(0===t.length)return{content:[{type:"text",text:`No tools found matching "${o.query}". Try different keywords.`}]};const e=new Map;for(const o of t){const t=e.get(o.service)||[];t.push(o),e.set(o.service,t)}const n=[`# Tools matching "${o.query}"`,""];for(const[o,t]of e){const e=isServiceLoaded(o);n.push(`## ${o} ${e?"(loaded)":"(not loaded)"}`),e||n.push(`> Load with: \`load_service(service_name: "${o}")\``),n.push("");for(const o of t)n.push(`- **${o.name}** — ${o.description} *(score: ${o.score})*`);n.push("")}return{content:[{type:"text",text:n.join("\n")}]}}
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ export declare const ListServicesSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
3
+ export declare const listServicesTool: {
4
+ name: string;
5
+ title: string;
6
+ description: string;
7
+ inputSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
8
+ annotations: {
9
+ readOnlyHint: boolean;
10
+ destructiveHint: boolean;
11
+ idempotentHint: boolean;
12
+ openWorldHint: boolean;
13
+ };
14
+ };
15
+ export declare function executeListServices(): Promise<{
16
+ content: {
17
+ type: "text";
18
+ text: string;
19
+ }[];
20
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{getServiceStatuses}from"../service-loader.js";export const ListServicesSchema=z.object({}).strict();export const listServicesTool={name:"list_services",title:"List Services",description:"Show all available DotZero services with their configuration and load status.\n\nServices:\n- **work-order**: Work orders, products, workers, routes, operations, reports, WMS (98 tools)\n- **spc**: Statistical Process Control - measure configs, history, dashboards, Nelson rules, Cpk (41 tools)\n- **equipment**: Machine status, alarms, idle tracking, part counts, realtime monitoring (12 tools)\n- **device-topology**: Factory/line/device hierarchy, plant floors, alarm codes (37 tools)\n- **oee**: Overall Equipment Effectiveness - availability, quality, performance metrics (20 tools)\n\nReturns: Service configuration and load status.",inputSchema:ListServicesSchema,annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};export async function executeListServices(){const e=getServiceStatuses(),o=["# DotZero Services","","| Service | Configured | Loaded | Tools | Action |","|---------|-----------|--------|-------|--------|"];for(const t of e){const e=t.configured?t.loaded?"Ready":`\`load_service(service_name: "${t.name}")\``:`Set \`${getEnvVar(t.name)}\``;o.push(`| ${t.name} | ${t.configured?"Yes":"No"} | ${t.loaded?"Yes":"No"} | ${t.toolCount} | ${e} |`)}const t=e.filter(e=>e.configured).length,r=e.filter(e=>e.loaded).length,i=e.reduce((e,o)=>e+o.toolCount,0);return o.push("",`**${t}** configured, **${r}** loaded, **${i}** total tools available`),{content:[{type:"text",text:o.join("\n")}]}}function getEnvVar(e){return{"work-order":"WORK_ORDER_API_URL",spc:"SPC_API_URL",equipment:"EQUIPMENT_API_URL","device-topology":"DEVICE_TOPOLOGY_API_URL",oee:"OEE_API_URL"}[e]||""}
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ export declare const LoadServiceSchema: z.ZodObject<{
4
+ service_name: z.ZodEnum<["work-order", "spc", "equipment", "device-topology", "oee"]>;
5
+ }, "strict", z.ZodTypeAny, {
6
+ service_name: "work-order" | "spc" | "equipment" | "device-topology" | "oee";
7
+ }, {
8
+ service_name: "work-order" | "spc" | "equipment" | "device-topology" | "oee";
9
+ }>;
10
+ export type LoadServiceInput = z.infer<typeof LoadServiceSchema>;
11
+ export declare function setServerRef(server: McpServer): void;
12
+ export declare const loadServiceTool: {
13
+ name: string;
14
+ title: string;
15
+ description: string;
16
+ inputSchema: z.ZodObject<{
17
+ service_name: z.ZodEnum<["work-order", "spc", "equipment", "device-topology", "oee"]>;
18
+ }, "strict", z.ZodTypeAny, {
19
+ service_name: "work-order" | "spc" | "equipment" | "device-topology" | "oee";
20
+ }, {
21
+ service_name: "work-order" | "spc" | "equipment" | "device-topology" | "oee";
22
+ }>;
23
+ annotations: {
24
+ readOnlyHint: boolean;
25
+ destructiveHint: boolean;
26
+ idempotentHint: boolean;
27
+ openWorldHint: boolean;
28
+ };
29
+ };
30
+ export declare function executeLoadService(params: LoadServiceInput): Promise<{
31
+ content: {
32
+ type: "text";
33
+ text: string;
34
+ }[];
35
+ isError: boolean;
36
+ } | {
37
+ content: {
38
+ type: "text";
39
+ text: string;
40
+ }[];
41
+ isError?: undefined;
42
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";import{loadService}from"../service-loader.js";export const LoadServiceSchema=z.object({service_name:z.enum(["work-order","spc","equipment","device-topology","oee"]).describe("Service to load")}).strict();let serverRef=null;export function setServerRef(e){serverRef=e}export const loadServiceTool={name:"load_service",title:"Load Service",description:"Load a DotZero service's tools into the gateway.\n\nAfter loading, the service's tools become available for use.\nRequires authentication first (use auth_login).\n\nAvailable services: work-order, spc, equipment, device-topology, oee\n\nReturns: Load status and tool count.",inputSchema:LoadServiceSchema,annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};export async function executeLoadService(e){if(!serverRef)return{content:[{type:"text",text:"Error: Server reference not set."}],isError:!0};const t=loadService(serverRef,e.service_name);return t.success?(serverRef.sendToolListChanged(),{content:[{type:"text",text:`# Service Loaded: ${e.service_name}\n\n${t.message}`}]}):{content:[{type:"text",text:t.message}],isError:!0}}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@dotzero.ai/dotzero-mcp",
3
+ "version": "1.2.0",
4
+ "description": "Unified DotZero MCP gateway - dynamically loads service modules on demand",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "dotzero-mcp": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "model-context-protocol",
20
+ "dotzero",
21
+ "mes",
22
+ "manufacturing",
23
+ "gateway",
24
+ "unified",
25
+ "claude",
26
+ "claude-code",
27
+ "ai-assistant"
28
+ ],
29
+ "author": {
30
+ "name": "DotZero",
31
+ "url": "https://dotzero.app"
32
+ },
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://gitlab.com/dotzero/dz-ai.git",
37
+ "directory": "packages/dotzero-mcp"
38
+ },
39
+ "bugs": {
40
+ "url": "https://gitlab.com/dotzero/dz-ai/-/issues"
41
+ },
42
+ "homepage": "https://gitlab.com/dotzero/dz-ai/-/blob/main/packages/dotzero-mcp/README.md",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "@modelcontextprotocol/sdk": "^1.6.1",
48
+ "axios": "^1.7.9",
49
+ "express": "^4.21.2",
50
+ "zod": "^3.23.8"
51
+ },
52
+ "devDependencies": {
53
+ "@types/express": "^5.0.0",
54
+ "@types/node": "^22.10.0",
55
+ "tsx": "^4.19.2",
56
+ "typescript": "^5.7.2"
57
+ },
58
+ "scripts": {
59
+ "start": "node dist/index.js",
60
+ "dev": "tsx watch src/index.ts",
61
+ "build": "tsc && find dist -name '*.js' -exec npx terser {} --compress --mangle -o {} \\;",
62
+ "clean": "rm -rf dist"
63
+ }
64
+ }