@coldbirds/mcp-server 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/dist/tools.js +1 -1
  2. package/package.json +1 -1
package/dist/tools.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.__internals=void 0,exports.registerTools=registerTools;const types_js_1=require("@modelcontextprotocol/sdk/types.js"),json_schema_to_zod_1=require("./json-schema-to-zod"),PLACEHOLDER_RE=/\{(\w+)\}/g;function pathParams(t){const n=[];for(const o of t.matchAll(PLACEHOLDER_RE)){const e=o[1];e&&n.push(e)}return n}function stringifyPathValue(t,n){if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new Error(`Path parameter '${t}' must be a string, number, or boolean (got ${typeof n})`)}function interpolate(t,n){return t.replace(PLACEHOLDER_RE,(o,e)=>{const r=n[e];if(r==null)throw new Error(`Missing required path parameter '${e}'`);return encodeURIComponent(stringifyPathValue(e,r))})}function remainingArgs(t,n){const o={};for(const[e,r]of Object.entries(t))n.includes(e)||(o[e]=r);return o}function asQuery(t){return t}async function dispatch(t,n,o){const{method:e,path:r}=n._http,i=pathParams(r),s=interpolate(r,o),c=remainingArgs(o,i),u=Object.keys(c).length>0;switch(e){case"GET":return t.get(s,u?c:void 0);case"POST":return t.post(s,u?c:void 0);case"PATCH":return t.patch(s,u?c:void 0);case"DELETE":return await t.delete(s)??{ok:!0}}}function ok(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function fail(t){return{content:[{type:"text",text:t}],isError:!0}}function buildHandler(t,n){return async o=>{try{const e=await dispatch(t,n,o);return ok(e)}catch(e){const r=e instanceof Error?e.message:String(e);return fail(`Tool '${n.name}' failed: ${r}`)}}}function buildInputSchema(t){const n=(0,json_schema_to_zod_1.jsonSchemaToZod)(t.inputSchema);if(n._def?.typeName!=="ZodObject")throw new Error(`Tool '${t.name}' inputSchema must be a JSON-Schema object at the root`);return n}function registerTools(t,n,o){for(const e of o.tools){const r={description:e.description,inputSchema:buildInputSchema(e)};e.title&&(r.title=e.title),t.registerTool(e.name,r,buildHandler(n,e))}t.server.setRequestHandler(types_js_1.ListToolsRequestSchema,()=>({tools:o.tools.map(e=>{const{_http:r,...i}=e;return i})}))}exports.__internals={dispatch,pathParams,interpolate,remainingArgs};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.__internals=void 0,exports.registerTools=registerTools;const types_js_1=require("@modelcontextprotocol/sdk/types.js"),json_schema_to_zod_1=require("./json-schema-to-zod"),PLACEHOLDER_RE=/\{(\w+)\}/g;function pathParams(t){const e=[];for(const o of t.matchAll(PLACEHOLDER_RE)){const n=o[1];n&&e.push(n)}return e}function stringifyPathValue(t,e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);throw new Error(`Path parameter '${t}' must be a string, number, or boolean (got ${typeof e})`)}function interpolate(t,e){return t.replace(PLACEHOLDER_RE,(o,n)=>{const r=e[n];if(r==null)throw new Error(`Missing required path parameter '${n}'`);return encodeURIComponent(stringifyPathValue(n,r))})}function remainingArgs(t,e){const o={};for(const[n,r]of Object.entries(t))e.includes(n)||(o[n]=r);return o}function asQuery(t){return t}async function dispatch(t,e,o){const{method:n,path:r}=e._http,s=pathParams(r),c=interpolate(r,o),u=remainingArgs(o,s),i=Object.keys(u).length>0;switch(n){case"GET":return t.get(c,i?u:void 0);case"POST":return t.post(c,i?u:void 0);case"PATCH":return t.patch(c,i?u:void 0);case"DELETE":return await t.delete(c)??{ok:!0}}}function ok(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function fail(t){return{content:[{type:"text",text:t}],isError:!0}}function isRecord(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function toStructured(t,e){if(!t.outputSchema||!isRecord(e))return;const o=t.outputSchema.properties;if(isRecord(o)&&"data"in o){const{success:r,...s}=e;return s}return"data"in e&&isRecord(e.data)?e.data:e}function buildHandler(t,e){return async o=>{try{const n=await dispatch(t,e,o),r=toStructured(e,n),s=ok(r??n);return r!==void 0?{...s,structuredContent:r}:s}catch(n){const r=n instanceof Error?n.message:String(n);return fail(`Tool '${e.name}' failed: ${r}`)}}}function buildInputSchema(t){const e=(0,json_schema_to_zod_1.jsonSchemaToZod)(t.inputSchema);if(e._def?.typeName!=="ZodObject")throw new Error(`Tool '${t.name}' inputSchema must be a JSON-Schema object at the root`);return e}function registerTools(t,e,o){for(const n of o.tools){const r={description:n.description,inputSchema:buildInputSchema(n)};n.title&&(r.title=n.title),t.registerTool(n.name,r,buildHandler(e,n))}t.server.setRequestHandler(types_js_1.ListToolsRequestSchema,()=>({tools:o.tools.map(n=>{const{_http:r,...s}=n;return s})}))}exports.__internals={dispatch,pathParams,interpolate,remainingArgs,toStructured};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldbirds/mcp-server",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for ColdBirds Sequence — control campaigns, contacts, and mailboxes from AI assistants like Claude Desktop, Cursor, and Windsurf.",
5
5
  "keywords": [
6
6
  "coldbirds",