@apexmcp/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ApexMCP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @apexmcp/sdk
2
+
3
+ Developer-first SDK for building **MCP (Model Context Protocol)** servers in the ApexMCP ecosystem.
4
+
5
+ ## Goals
6
+
7
+ - **Tiny**: a working MCP server in <10 LOC
8
+ - **Elegant**: fluent builder API with good defaults
9
+ - **Extensible**: plugins/hooks, plus escape hatches to the underlying `McpServer`
10
+ - **Compatible**: built on the official `@modelcontextprotocol/sdk`
11
+
12
+ ## Quick start (STDIO)
13
+
14
+ ```ts
15
+ import { apex, t } from '@apexmcp/sdk';
16
+
17
+ const server = apex
18
+ .createServer('my-server', '0.1.0')
19
+ .tool({
20
+ name: 'hello',
21
+ description: 'Say hello',
22
+ input: t.Object({ name: t.String() }),
23
+ handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
24
+ });
25
+
26
+ await server.listenStdio();
27
+ ```
28
+
29
+ ## Quick start (HTTP-only, Deno Deploy)
30
+
31
+ ```ts
32
+ import { apex, t } from '@apexmcp/sdk';
33
+
34
+ const server = apex
35
+ .createServer('my-server', '0.1.0')
36
+ .tool({
37
+ name: 'hello',
38
+ description: 'Say hello',
39
+ input: t.Object({ name: t.String() }),
40
+ handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
41
+ });
42
+
43
+ export const fetch = server.fetch; // serves MCP on /mcp (and /health)
44
+ ```
45
+
46
+ ## Mount into an existing router (example: Hono)
47
+
48
+ ```ts
49
+ import { Hono } from 'hono';
50
+ import { apex, t } from '@apexmcp/sdk';
51
+
52
+ const server = apex
53
+ .createServer('my-server', '0.1.0')
54
+ .tool({
55
+ name: 'hello',
56
+ description: 'Say hello',
57
+ input: t.Object({ name: t.String() }),
58
+ handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
59
+ });
60
+
61
+ const app = new Hono();
62
+ const { mcp, health } = server.routes();
63
+
64
+ app.all('/mcp', c => mcp(c.req.raw));
65
+ app.get('/health', c => health(c.req.raw));
66
+
67
+ export const fetch = app.fetch;
68
+ ```
69
+
70
+ ## API highlights
71
+
72
+ - `apex.createServer(name, version, options?)`
73
+ - `server.tool({ name, description, input, handler, ... })`
74
+ - `server.resource({ name, uri, mimeType?, handler, ... })`
75
+ - `server.use(plugin)`
76
+ - `server.onShutdown(fn)`
77
+ - `server.fetch` / `server.asFetch({ mcpPath, healthPath })`
78
+ - `server.routes()` (router-friendly `{ mcp, health }`)
79
+ - `server.mcp` (escape hatch to the official MCP server)
80
+
@@ -0,0 +1,102 @@
1
+ import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { Variables } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
4
+ import { ServerCapabilities, ToolAnnotations, CallToolResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
5
+ import { TSchema, Static } from '@sinclair/typebox';
6
+ export { Static, TSchema, Type, Type as t } from '@sinclair/typebox';
7
+
8
+ type ToolHandlerResult = CallToolResult;
9
+ type ToolHandler<S extends TSchema = TSchema> = (args: Static<S>) => Promise<ToolHandlerResult> | ToolHandlerResult;
10
+ type ToolDefinition<S extends TSchema = TSchema> = {
11
+ name: string;
12
+ title?: string;
13
+ description: string;
14
+ input: S;
15
+ output?: TSchema;
16
+ annotations?: ToolAnnotations;
17
+ handler: ToolHandler<S>;
18
+ };
19
+ type ResourceHandlerResult = ReadResourceResult;
20
+ type ResourceHandler = (uri: string, variables?: Variables) => Promise<ResourceHandlerResult> | ResourceHandlerResult;
21
+ type ResourceDefinition = {
22
+ name: string;
23
+ /**
24
+ * Use a concrete URI (`"apex://foo"`) or a `ResourceTemplate` from the MCP SDK.
25
+ * Re-exported as `ResourceTemplate` from `@apexmcp/sdk`.
26
+ */
27
+ uri: string | ResourceTemplate;
28
+ mimeType?: string;
29
+ description?: string;
30
+ handler: ResourceHandler;
31
+ };
32
+ type ApexPlugin = (server: ApexServer) => void | Promise<void>;
33
+ type ApexServerOptions = {
34
+ title?: string;
35
+ instructions?: string;
36
+ capabilities?: ServerCapabilities;
37
+ };
38
+ type ApexServer = {
39
+ readonly mcp: McpServer;
40
+ tool<S extends TSchema>(def: ToolDefinition<S>): ApexServer;
41
+ resource(def: ResourceDefinition): ApexServer;
42
+ /**
43
+ * Web-standard MCP handler for HTTP-only deployments (Deno Deploy, Bun, Workers, etc).
44
+ *
45
+ * Default behavior:
46
+ * - `/mcp` -> MCP Streamable HTTP transport handler
47
+ * - `/health` -> 200 JSON health check
48
+ */
49
+ readonly fetch: (request: Request) => Promise<Response>;
50
+ /**
51
+ * Create a `fetch` handler with custom routing.
52
+ */
53
+ asFetch(options?: {
54
+ mcpPath?: string;
55
+ healthPath?: string;
56
+ }): (request: Request) => Promise<Response>;
57
+ /**
58
+ * Router-friendly handlers for mounting into existing frameworks (Hono/Oak/etc).
59
+ *
60
+ * These handlers assume the router has already matched the path.
61
+ */
62
+ routes(): {
63
+ mcp: (request: Request) => Promise<Response>;
64
+ health: (request: Request) => Promise<Response>;
65
+ };
66
+ /**
67
+ * Install an extension/plugin that can register tools/resources and hooks.
68
+ */
69
+ use(plugin: ApexPlugin): ApexServer;
70
+ /**
71
+ * Wire up STDIO transport and start serving MCP requests.
72
+ * Includes a SIGINT handler by default.
73
+ */
74
+ listenStdio(options?: {
75
+ handleSigint?: boolean;
76
+ }): Promise<void>;
77
+ /**
78
+ * Adds a callback that runs during shutdown.
79
+ */
80
+ onShutdown(cb: () => void | Promise<void>): ApexServer;
81
+ /**
82
+ * Lightweight dev manifest for introspection/testing.
83
+ */
84
+ manifest(): {
85
+ name: string;
86
+ version: string;
87
+ tools: Array<Pick<ToolDefinition, 'name' | 'title' | 'description'>>;
88
+ resources: Array<Pick<ResourceDefinition, 'name' | 'uri' | 'mimeType'>>;
89
+ };
90
+ };
91
+
92
+ declare function text(text: string, structuredContent?: Record<string, unknown>): ToolHandlerResult;
93
+ declare function json(value: unknown): ToolHandlerResult;
94
+
95
+ declare function createServer(name: string, version: string, options?: ApexServerOptions): ApexServer;
96
+ declare const apex: {
97
+ createServer: typeof createServer;
98
+ text: typeof text;
99
+ json: typeof json;
100
+ };
101
+
102
+ export { type ApexPlugin, type ApexServer, type ApexServerOptions, type ResourceDefinition, type ResourceHandler, type ToolDefinition, type ToolHandler, apex, createServer };
package/dist/index.js ADDED
@@ -0,0 +1,185 @@
1
+ // src/lib/apex.ts
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
5
+
6
+ // src/lib/content.ts
7
+ function text(text2, structuredContent) {
8
+ return {
9
+ content: [{ type: "text", text: text2 }],
10
+ ...structuredContent === void 0 ? {} : { structuredContent }
11
+ };
12
+ }
13
+ function json(value) {
14
+ const structured = typeof value === "object" && value !== null ? value : { value };
15
+ return text(JSON.stringify(value, null, 2), structured);
16
+ }
17
+
18
+ // src/lib/helpers.ts
19
+ function writeStderr(line) {
20
+ if (typeof process !== "undefined" && process.stderr?.write) {
21
+ process.stderr.write(`${line}
22
+ `);
23
+ return;
24
+ }
25
+ }
26
+
27
+ // src/lib/apex.ts
28
+ var ApexServerImpl = class {
29
+ mcp;
30
+ info;
31
+ shutdownHandlers = [];
32
+ toolIndex = [];
33
+ resourceIndex = [];
34
+ closing = false;
35
+ webTransport;
36
+ webConnected;
37
+ cachedRoutes;
38
+ constructor(info, options = {}, mcp) {
39
+ this.info = info;
40
+ this.mcp = mcp ?? new McpServer(
41
+ { name: info.name, title: options.title ?? info.name, version: info.version },
42
+ options.instructions || options.capabilities ? { instructions: options.instructions, capabilities: options.capabilities } : void 0
43
+ );
44
+ }
45
+ fetch = async (request) => {
46
+ return await this.asFetch()(request);
47
+ };
48
+ asFetch(options = {}) {
49
+ const mcpPath = options.mcpPath ?? "/mcp";
50
+ const healthPath = options.healthPath ?? "/health";
51
+ return async (request) => {
52
+ const url = new URL(request.url);
53
+ if (url.pathname === healthPath) return await this.routes().health(request);
54
+ if (url.pathname !== mcpPath) {
55
+ return new Response(JSON.stringify({ error: "Not Found" }), {
56
+ status: 404,
57
+ headers: { "Content-Type": "application/json" }
58
+ });
59
+ }
60
+ return await this.routes().mcp(request);
61
+ };
62
+ }
63
+ routes() {
64
+ if (this.cachedRoutes) return this.cachedRoutes;
65
+ const health = async (_request) => {
66
+ return new Response(JSON.stringify({ status: "ok" }), {
67
+ status: 200,
68
+ headers: { "Content-Type": "application/json" }
69
+ });
70
+ };
71
+ const mcp = async (request) => {
72
+ if (!this.webTransport) {
73
+ this.webTransport = new WebStandardStreamableHTTPServerTransport();
74
+ }
75
+ if (!this.webConnected) {
76
+ this.webConnected = this.mcp.connect(this.webTransport);
77
+ }
78
+ await this.webConnected;
79
+ return await this.webTransport.handleRequest(request);
80
+ };
81
+ this.cachedRoutes = { mcp, health };
82
+ return this.cachedRoutes;
83
+ }
84
+ tool(def) {
85
+ this.toolIndex.push({
86
+ name: def.name,
87
+ title: def.title,
88
+ description: def.description
89
+ });
90
+ this.mcp.registerTool(
91
+ def.name,
92
+ {
93
+ title: def.title ?? def.name,
94
+ description: def.description,
95
+ // MCP SDK accepts Zod shapes or generic JSON schemas (AnySchema). TypeBox schemas are JSON schemas.
96
+ inputSchema: def.input,
97
+ ...def.output ? { outputSchema: def.output } : {},
98
+ ...def.annotations ? { annotations: def.annotations } : {}
99
+ },
100
+ (async (args) => await def.handler(args))
101
+ );
102
+ return this;
103
+ }
104
+ resource(def) {
105
+ this.resourceIndex.push({
106
+ name: def.name,
107
+ uri: def.uri,
108
+ mimeType: def.mimeType
109
+ });
110
+ const config = {
111
+ ...def.mimeType ? { mimeType: def.mimeType } : {},
112
+ ...def.description ? { description: def.description } : {}
113
+ };
114
+ if (typeof def.uri === "string") {
115
+ this.mcp.registerResource(def.name, def.uri, config, async (uri) => {
116
+ return await def.handler(uri.toString(), void 0);
117
+ });
118
+ } else {
119
+ this.mcp.registerResource(def.name, def.uri, config, async (uri, variables) => {
120
+ return await def.handler(uri.toString(), variables);
121
+ });
122
+ }
123
+ return this;
124
+ }
125
+ use(plugin) {
126
+ void Promise.resolve(plugin(this));
127
+ return this;
128
+ }
129
+ onShutdown(cb) {
130
+ this.shutdownHandlers.push(cb);
131
+ return this;
132
+ }
133
+ manifest() {
134
+ return {
135
+ name: this.info.name,
136
+ version: this.info.version,
137
+ tools: [...this.toolIndex],
138
+ resources: [...this.resourceIndex]
139
+ };
140
+ }
141
+ async listenStdio(options = {}) {
142
+ const transport = new StdioServerTransport();
143
+ await this.mcp.connect(transport);
144
+ writeStderr(`${this.info.name} MCP server running on stdio`);
145
+ if (options.handleSigint !== false && typeof process !== "undefined") {
146
+ process.on("SIGINT", () => {
147
+ void this.closeAndExit(0);
148
+ });
149
+ }
150
+ }
151
+ async closeAndExit(exitCode) {
152
+ if (this.closing) return;
153
+ this.closing = true;
154
+ try {
155
+ await this.mcp.close();
156
+ } finally {
157
+ for (const fn of this.shutdownHandlers) {
158
+ await fn();
159
+ }
160
+ if (typeof process !== "undefined" && typeof process.exit === "function") {
161
+ process.exit(exitCode);
162
+ }
163
+ }
164
+ }
165
+ };
166
+ function createServer(name, version, options) {
167
+ return new ApexServerImpl({ name, version }, options);
168
+ }
169
+ var apex = {
170
+ createServer,
171
+ text,
172
+ json
173
+ };
174
+
175
+ // src/index.ts
176
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
177
+ import { Type, Type as Type2 } from "@sinclair/typebox";
178
+ export {
179
+ ResourceTemplate,
180
+ Type,
181
+ apex,
182
+ createServer,
183
+ Type2 as t
184
+ };
185
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/apex.ts","../src/lib/content.ts","../src/lib/helpers.ts","../src/index.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';\nimport type { AnySchema } from '@modelcontextprotocol/sdk/server/zod-compat.js';\nimport type { Variables } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';\nimport type { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { TSchema } from '@sinclair/typebox';\n\nimport { json, text } from './content.js';\nimport { writeStderr } from './helpers.js';\nimport type {\n ApexPlugin,\n ApexServer,\n ApexServerOptions,\n ResourceDefinition,\n ToolDefinition,\n ToolHandlerResult,\n} from './types.js';\n\ntype ServerInfo = { name: string; version: string };\n\nclass ApexServerImpl implements ApexServer {\n public readonly mcp: McpServer;\n\n private readonly info: ServerInfo;\n private readonly shutdownHandlers: Array<() => void | Promise<void>> = [];\n private readonly toolIndex: Array<Pick<ToolDefinition, 'name' | 'title' | 'description'>> = [];\n private readonly resourceIndex: Array<Pick<ResourceDefinition, 'name' | 'uri' | 'mimeType'>> =\n [];\n private closing = false;\n private webTransport?: WebStandardStreamableHTTPServerTransport;\n private webConnected?: Promise<void>;\n private cachedRoutes?: ReturnType<ApexServer['routes']>;\n\n public constructor(info: ServerInfo, options: ApexServerOptions = {}, mcp?: McpServer) {\n this.info = info;\n this.mcp =\n mcp ??\n new McpServer(\n { name: info.name, title: options.title ?? info.name, version: info.version },\n options.instructions || options.capabilities\n ? { instructions: options.instructions, capabilities: options.capabilities }\n : undefined\n );\n }\n\n public readonly fetch = async (request: Request): Promise<Response> => {\n return await this.asFetch()(request);\n };\n\n public asFetch(\n options: { mcpPath?: string; healthPath?: string } = {}\n ): (request: Request) => Promise<Response> {\n const mcpPath = options.mcpPath ?? '/mcp';\n const healthPath = options.healthPath ?? '/health';\n\n return async (request: Request): Promise<Response> => {\n const url = new URL(request.url);\n\n if (url.pathname === healthPath) return await this.routes().health(request);\n\n if (url.pathname !== mcpPath) {\n return new Response(JSON.stringify({ error: 'Not Found' }), {\n status: 404,\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n return await this.routes().mcp(request);\n };\n }\n\n public routes(): ReturnType<ApexServer['routes']> {\n if (this.cachedRoutes) return this.cachedRoutes;\n\n const health = async (_request: Request): Promise<Response> => {\n return new Response(JSON.stringify({ status: 'ok' }), {\n status: 200,\n headers: { 'Content-Type': 'application/json' },\n });\n };\n\n const mcp = async (request: Request): Promise<Response> => {\n if (!this.webTransport) {\n // Default is stateless (sessionIdGenerator undefined), perfect for HTTP-only serverless deploys.\n this.webTransport = new WebStandardStreamableHTTPServerTransport();\n }\n if (!this.webConnected) {\n this.webConnected = this.mcp.connect(this.webTransport);\n }\n await this.webConnected;\n return await this.webTransport.handleRequest(request);\n };\n\n this.cachedRoutes = { mcp, health };\n return this.cachedRoutes;\n }\n\n public tool<S extends TSchema>(def: ToolDefinition<S>): ApexServer {\n this.toolIndex.push({\n name: def.name,\n title: def.title,\n description: def.description,\n });\n\n this.mcp.registerTool(\n def.name,\n {\n title: def.title ?? def.name,\n description: def.description,\n // MCP SDK accepts Zod shapes or generic JSON schemas (AnySchema). TypeBox schemas are JSON schemas.\n inputSchema: def.input as unknown as AnySchema,\n ...(def.output ? { outputSchema: def.output as unknown as AnySchema } : {}),\n ...(def.annotations ? { annotations: def.annotations } : {}),\n },\n (async (args: unknown) => await def.handler(args as any)) as unknown as ToolCallback<AnySchema>\n );\n\n return this;\n }\n\n public resource(def: ResourceDefinition): ApexServer {\n this.resourceIndex.push({\n name: def.name,\n uri: def.uri,\n mimeType: def.mimeType,\n });\n\n const config = {\n ...(def.mimeType ? { mimeType: def.mimeType } : {}),\n ...(def.description ? { description: def.description } : {}),\n };\n\n if (typeof def.uri === 'string') {\n this.mcp.registerResource(def.name, def.uri, config, async (uri: URL) => {\n return await def.handler(uri.toString(), undefined);\n });\n } else {\n this.mcp.registerResource(def.name, def.uri, config, async (uri: URL, variables: Variables) => {\n return await def.handler(uri.toString(), variables);\n });\n }\n\n return this;\n }\n\n public use(plugin: ApexPlugin): ApexServer {\n // Support async plugins without forcing `.use()` to be async.\n void Promise.resolve(plugin(this));\n return this;\n }\n\n public onShutdown(cb: () => void | Promise<void>): ApexServer {\n this.shutdownHandlers.push(cb);\n return this;\n }\n\n public manifest(): ReturnType<ApexServer['manifest']> {\n return {\n name: this.info.name,\n version: this.info.version,\n tools: [...this.toolIndex],\n resources: [...this.resourceIndex],\n };\n }\n\n public async listenStdio(options: { handleSigint?: boolean } = {}): Promise<void> {\n const transport = new StdioServerTransport();\n await this.mcp.connect(transport);\n\n writeStderr(`${this.info.name} MCP server running on stdio`);\n\n if (options.handleSigint !== false && typeof process !== 'undefined') {\n process.on('SIGINT', () => {\n void this.closeAndExit(0);\n });\n }\n }\n\n private async closeAndExit(exitCode: number): Promise<void> {\n if (this.closing) return;\n this.closing = true;\n\n try {\n await this.mcp.close();\n } finally {\n for (const fn of this.shutdownHandlers) {\n await fn();\n }\n if (typeof process !== 'undefined' && typeof process.exit === 'function') {\n process.exit(exitCode);\n }\n }\n }\n}\n\nexport function createServer(\n name: string,\n version: string,\n options?: ApexServerOptions\n): ApexServer {\n return new ApexServerImpl({ name, version }, options);\n}\n\nexport const apex = {\n createServer,\n text,\n json,\n};\n\n\n","import type { ToolHandlerResult } from './types.js';\n\nexport function text(\n text: string,\n structuredContent?: Record<string, unknown>\n): ToolHandlerResult {\n return {\n content: [{ type: 'text', text }],\n ...(structuredContent === undefined ? {} : { structuredContent }),\n };\n}\n\nexport function json(value: unknown): ToolHandlerResult {\n const structured =\n typeof value === 'object' && value !== null\n ? (value as Record<string, unknown>)\n : { value };\n return text(JSON.stringify(value, null, 2), structured);\n}\n\n\n","export function writeStderr(line: string): void {\n // Node/Bun\n if (typeof process !== 'undefined' && process.stderr?.write) {\n process.stderr.write(`${line}\\n`);\n return;\n }\n}\n\n\n","export { apex, createServer } from './lib/apex.js';\nexport type {\n ApexServer,\n ApexServerOptions,\n ApexPlugin,\n ToolDefinition,\n ToolHandler,\n ResourceDefinition,\n ResourceHandler,\n} from './lib/types.js';\n\nexport { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport { Type, Type as t } from '@sinclair/typebox';\nexport type { Static, TSchema } from '@sinclair/typebox';\n\n\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,gDAAgD;;;ACAlD,SAAS,KACdA,OACA,mBACmB;AACnB,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAAA,MAAK,CAAC;AAAA,IAChC,GAAI,sBAAsB,SAAY,CAAC,IAAI,EAAE,kBAAkB;AAAA,EACjE;AACF;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iB,SAAS,OAAO,YAAY,aAAa;AACpE,cAAQ,GAAG,UAAU,MAAM;AACzB,aAAK,KAAK,aAAa,CAAC;AAAA,MAC1B,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,MAAc,aAAa,UAAiC;AAC1D,QAAI,KAAK,QAAS;AAClB,SAAK,UAAU;AAEf,QAAI;AACF,YAAM,KAAK,IAAI,MAAM;AAAA,IACvB,UAAE;AACA,iBAAW,MAAM,KAAK,kBAAkB;AACtC,cAAM,GAAG;AAAA,MACX;AACA,UAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,SAAS,YAAY;AACxE,gBAAQ,KAAK,QAAQ;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,aACd,MACA,SACA,SACY;AACZ,SAAO,IAAI,eAAe,EAAE,MAAM,QAAQ,GAAG,OAAO;AACtD;AAEO,IAAM,OAAO;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF;;;AGrMA,SAAS,wBAAwB;AAEjC,SAAS,MAAc,QAARC,aAAiB;","names":["text","Type"]}
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@apexmcp/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Developer-first SDK for building MCP (Model Context Protocol) servers in the ApexMCP ecosystem.",
5
+ "author": "@keyrxng",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "engines": {
23
+ "node": ">=18.18.0"
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "test": "jest --coverage",
29
+ "test:watch": "jest --watch",
30
+ "test:ci": "jest --coverage --ci --reporters=default --reporters=jest-junit",
31
+ "format": "run-s format:lint format:prettier format:cspell",
32
+ "format:lint": "eslint --fix .",
33
+ "format:prettier": "prettier --write .",
34
+ "format:cspell": "cspell **/*",
35
+ "typecheck": "tsc --noEmit",
36
+ "knip": "knip",
37
+ "clean": "rm -rf dist coverage .swc",
38
+ "prepublishOnly": "bun run clean && bun run build && bun run test",
39
+ "prepare": "husky install || true"
40
+ },
41
+ "keywords": [
42
+ "apexmcp",
43
+ "mcp",
44
+ "model-context-protocol",
45
+ "sdk",
46
+ "typescript",
47
+ "server",
48
+ "tools",
49
+ "resources"
50
+ ],
51
+ "dependencies": {
52
+ "@modelcontextprotocol/sdk": "^1.24.0",
53
+ "@sinclair/typebox": "^0.34.41"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/config-conventional": "^20.2.0",
57
+ "@jest/globals": "^30.2.0",
58
+ "@mswjs/data": "^0.16.2",
59
+ "@semantic-release/changelog": "^6.0.3",
60
+ "@semantic-release/git": "^10.0.1",
61
+ "@swc/core": "^1.15.4",
62
+ "@swc/jest": "^0.2.39",
63
+ "@types/bun": "^1.3.4",
64
+ "@types/deno": "^2.5.0",
65
+ "@types/jest": "^30.0.0",
66
+ "@types/node": "^25.0.2",
67
+ "cspell": "^9.4.0",
68
+ "dotenv": "^17.2.3",
69
+ "eslint": "^9.39.2",
70
+ "eslint-config-prettier": "^10.1.8",
71
+ "eslint-plugin-import": "^2.32.0",
72
+ "eslint-plugin-sonarjs": "^3.0.5",
73
+ "husky": "^9.1.7",
74
+ "jest": "^30.2.0",
75
+ "jest-junit": "^16.0.0",
76
+ "knip": "^5.73.4",
77
+ "lint-staged": "^16.2.7",
78
+ "msw": "^2.12.4",
79
+ "npm-run-all": "^4.1.5",
80
+ "prettier": "^3.1.0",
81
+ "tsup": "^8.5.0",
82
+ "typescript": "^5.9.3",
83
+ "typescript-eslint": "^8.49.0"
84
+ },
85
+ "lint-staged": {
86
+ "*.ts": [
87
+ "prettier --write",
88
+ "eslint --fix"
89
+ ],
90
+ "src/**.{ts,json}": [
91
+ "cspell"
92
+ ]
93
+ },
94
+ "private": false
95
+ }