@appport/mcp 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,126 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to Licensor for inclusion in the Work by the copyright owner
48
+ or by an individual or Legal Entity authorized to submit on behalf of
49
+ the copyright owner.
50
+
51
+ "Contributor" shall mean Licensor and any individual or Legal Entity
52
+ on behalf of whom a Contribution has been received by Licensor and
53
+ subsequently incorporated within the Work.
54
+
55
+ 2. Grant of Copyright License. Subject to the terms and conditions of
56
+ this License, each Contributor hereby grants to You a perpetual,
57
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
58
+ copyright license to reproduce, prepare Derivative Works of,
59
+ publicly display, publicly perform, sublicense, and distribute the
60
+ Work and such Derivative Works in Source or Object form.
61
+
62
+ 3. Grant of Patent License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ (except as stated in this section) patent license to make, have made,
66
+ use, offer to sell, sell, import, and otherwise transfer the Work.
67
+
68
+ 4. Redistribution. You may reproduce and distribute copies of the
69
+ Work or Derivative Works thereof in any medium, with or without
70
+ modifications, and in Source or Object form, provided that You
71
+ meet the following conditions:
72
+
73
+ (a) You must give any other recipients of the Work or
74
+ Derivative Works a copy of this License; and
75
+
76
+ (b) You must cause any modified files to carry prominent notices
77
+ stating that You changed the files; and
78
+
79
+ (c) You must retain, in the Source form of any Derivative Works
80
+ that You distribute, all copyright, patent, trademark, and
81
+ attribution notices from the Source form of the Work; and
82
+
83
+ (d) If the Work includes a "NOTICE" text file as part of its
84
+ distribution, then any Derivative Works that You distribute must
85
+ include a readable copy of the attribution notices contained
86
+ within such NOTICE file.
87
+
88
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
89
+ any Contribution intentionally submitted for inclusion in the Work
90
+ by You to the Licensor shall be under the terms and conditions of
91
+ this License, without any additional terms or conditions.
92
+
93
+ 6. Trademarks. This License does not grant permission to use the trade
94
+ names, trademarks, service marks, or product names of the Licensor.
95
+
96
+ 7. Disclaimer of Warranty. Unless required by applicable law or
97
+ agreed to in writing, Licensor provides the Work (and each
98
+ Contributor provides its Contributions) on an "AS IS" BASIS,
99
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
100
+ implied.
101
+
102
+ 8. Limitation of Liability. In no event and under no legal theory,
103
+ whether in tort (including negligence), contract, or otherwise,
104
+ shall any Contributor be liable to You for damages.
105
+
106
+ 9. Accepting Warranty or Additional Liability. While redistributing
107
+ the Work or Derivative Works thereof, You may choose to offer,
108
+ and charge a fee for, acceptance of support, warranty, indemnity,
109
+ or other liability obligations and/or rights consistent with this
110
+ License.
111
+
112
+ END OF TERMS AND CONDITIONS
113
+
114
+ Copyright 2026 AppPort contributors
115
+
116
+ Licensed under the Apache License, Version 2.0 (the "License");
117
+ you may not use this file except in compliance with the License.
118
+ You may obtain a copy of the License at
119
+
120
+ http://www.apache.org/licenses/LICENSE-2.0
121
+
122
+ Unless required by applicable law or agreed to in writing, software
123
+ distributed under the License is distributed on an "AS IS" BASIS,
124
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125
+ See the License for the specific language governing permissions and
126
+ limitations under the License.
package/README.md CHANGED
@@ -1,29 +1,166 @@
1
1
  # @appport/mcp
2
2
 
3
- Expose AppPort capabilities as MCP tools.
3
+ The MCP adapter for AppPort: exposes an AppPort application's capabilities to
4
+ any MCP client (agents, IDEs, other hosts) over the official
5
+ [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk).
4
6
 
5
- ```ts
6
- import { createMcpBridge } from "@appport/mcp";
7
-
8
- const bridge = createMcpBridge(application, { session });
7
+ ## Architecture
9
8
 
10
- bridge.listTools();
11
- await bridge.callTool("documents_save", { documentId, content });
9
+ ```
10
+ AppPort (authority: capabilities, authorization, idempotency, timeouts)
11
+ │
12
+ ┌─────────┴──────────┐
13
+ native clients @appport/mcp ──► MCP clients
12
14
  ```
13
15
 
14
- The layering matters:
16
+ **AppPort is the authority; MCP is a projection.** This package defines no
17
+ capabilities, permissions, tenants, operations, persistence or business logic,
18
+ and retains no state between calls. Each MCP `tools/call` is translated into an
19
+ `AppRequest` and dispatched through `AppPortApplication.handleRequest` — the same
20
+ pipeline every other transport uses — so validation, authorization, idempotency,
21
+ timeouts, telemetry and handler execution are unchanged. JSON-RPC, protocol
22
+ negotiation, framing and transports are the MCP SDK's; none is reimplemented here.
15
23
 
16
24
  ```
17
- AI -> MCP -> AppPort -> application
25
+ MCP tools/call → @appport/mcp → AppRequest → application.handleRequest
26
+ → validate → authorize → capability handler
27
+ ```
28
+
29
+ ## Server setup
30
+
31
+ `createMcpHandler` returns a standard `(Request) => Promise<Response>` function
32
+ serving MCP Streamable HTTP. It is stateless — each HTTP request gets its own
33
+ short-lived SDK server and transport and is answered as one JSON response — so it
34
+ runs on serverless platforms and any fetch-compatible runtime without sticky
35
+ sessions or a long-lived process. `GET` and `DELETE` (server-initiated streams,
36
+ session teardown) are declined with `405`, which MCP permits.
37
+
38
+ ```ts
39
+ import { createMcpHandler } from "@appport/mcp";
40
+ import { errors } from "@appport/protocol";
41
+
42
+ const handler = createMcpHandler(application, {
43
+ // Runs per MCP request. Verify credentials, then say who the caller is.
44
+ async context({ headers, authInfo }) {
45
+ const token = headers["authorization"]?.toString().replace(/^Bearer /, "");
46
+ if (!token) return undefined; // anonymous: AppPort allows only public capabilities
47
+ const session = await myApp.verify(token); // your AppPort `Session`
48
+ if (!session) throw errors.unauthorized("Invalid credentials");
49
+ return { session };
50
+ }
51
+ });
52
+
53
+ // e.g. a Next.js / Vercel route handler
54
+ export const POST = (request: Request) => handler(request);
55
+ export const GET = POST;
56
+ export const DELETE = POST;
18
57
  ```
19
58
 
20
- AppPort does not compete with MCP; it is the application protocol underneath it.
21
- A capability that is already defined, validated, versioned and authorized becomes
22
- an agent tool without a second definition, and the agent's session decides what
23
- it may call. A tool call runs the same dispatch pipeline as any other request, so
24
- `INVALID_INPUT` and `FORBIDDEN` reach the agent as tool errors rather than as
25
- unexpected behaviour.
59
+ For stdio or in-memory use, `createMcpServer(application, options)` returns the
60
+ SDK `Server` to connect to any SDK transport.
61
+
62
+ Options (`McpServerOptions`): `context`, `serverInfo` (defaults to the
63
+ application's name and version), `include`, `prefix`, `includeBuiltins`.
64
+
65
+ The host owns deployment, routing, TLS, origin/DNS-rebinding checks, rate
66
+ limiting and credential verification. The host may also verify the credential
67
+ before calling the handler and pass it as `handler(request, { authInfo })`; it
68
+ then reaches `context` as `authInfo`.
69
+
70
+ ## Authentication
71
+
72
+ The adapter never authenticates callers and never trusts them implicitly. The
73
+ host supplies the authenticated `session` and/or `principal` — the same values a
74
+ native transport passes in AppPort's `DispatchOptions` — through `context`.
75
+
76
+ - No `context` option, or `context` returns nothing → the call is dispatched
77
+ anonymously. AppPort's authorizer refuses any capability that requires
78
+ permissions (`UNAUTHORIZED`); only public capabilities run.
79
+ - `context` throws an `AppPortError` (`UNAUTHORIZED`/`FORBIDDEN`) → reported as a
80
+ tool error. Any other exception is reported as a JSON-RPC internal error with
81
+ no detail.
82
+ - Identity cannot be supplied by the MCP caller in tool arguments or `_meta`.
83
+
84
+ Idempotency keys are scoped by AppPort to the session, so provide a stable,
85
+ per-caller `session.id`.
86
+
87
+ ## Capability exposure
88
+
89
+ Tools are derived from the application manifest on every request; there is no
90
+ second list.
91
+
92
+ | AppPort | MCP tool |
93
+ | --- | --- |
94
+ | request capability `call.create` | tool `call_create` (`.` → `_`, optional `prefix`) |
95
+ | capability `inputSchema` | tool `inputSchema` (must be an object schema) |
96
+ | capability `outputSchema` | tool `outputSchema` (when an object schema) |
97
+ | capability name/version/permissions | tool `_meta["dev.appport/capability"]` |
98
+
99
+ The tool name is a label, not an identity: calls resolve through the manifest.
100
+ Two capabilities projecting to one tool name is an error, not an overwrite.
101
+ Stream capabilities, non-object inputs and the reserved `appport.*` namespace
102
+ (unless `includeBuiltins`) are not exposed. Tool discovery lists what the
103
+ application publishes; it does not filter by caller — authorization is enforced
104
+ when a tool is called.
105
+
106
+ ## Metadata
107
+
108
+ AppPort request metadata is carried in the MCP `tools/call` `_meta` object and
109
+ placed, unchanged, on the `AppRequest` (`MCP_META` exports the keys):
110
+
111
+ | `_meta` key | AppPort field | Notes |
112
+ | --- | --- | --- |
113
+ | `dev.appport/idempotencyKey` | `idempotencyKey` | replay is AppPort's (§13.1); this package keeps no cache |
114
+ | `dev.appport/timeoutMs` | `timeoutMs` | becomes the capability's deadline; AppPort clamps it (§13.3); no MCP default is added |
115
+ | `dev.appport/traceId` | `traceId` | reaches `context.traceId`; AppPort generates one if absent; echoed on the result `_meta` |
116
+
117
+ Malformed values (empty strings, non-positive timeouts) are rejected as
118
+ `INVALID_REQUEST`. MCP request cancellation and HTTP client disconnects abort
119
+ the capability's `context.signal`.
120
+
121
+ ## Errors
122
+
123
+ Protocol-level problems use JSON-RPC errors from the SDK: malformed JSON or
124
+ messages (`-32700`/`-32600`), unknown method (`-32601`), unknown tool (`-32602`),
125
+ and adapter failures (`-32603`, no detail). Every AppPort outcome is a tool
126
+ result: success has `content` (JSON text) and `structuredContent`; failure has
127
+ `isError: true`, text `CODE: message`, and `_meta["dev.appport/error"]`
128
+ (`MCP_ERROR_META`) with `{ code, category, retryable, details? }`. `details` is
129
+ what AppPort already sanitized (§16).
130
+
131
+ | AppPort code | `category` |
132
+ | --- | --- |
133
+ | `INVALID_REQUEST`, `INVALID_INPUT`, `INVALID_PROTOCOL`, `UNSUPPORTED_VERSION`, `UNSUPPORTED_CAPABILITY_VERSION`, `PAYLOAD_TOO_LARGE`, `NO_COMPATIBLE_MATERIALIZATION` | `invalid_request` |
134
+ | `UNAUTHORIZED` | `unauthenticated` |
135
+ | `FORBIDDEN` | `forbidden` |
136
+ | `NOT_FOUND`, `UNKNOWN_CAPABILITY` | `not_found` |
137
+ | `CONFLICT` | `conflict` |
138
+ | `TIMEOUT` | `timeout` |
139
+ | `RATE_LIMITED` | `rate_limited` |
140
+ | `CANCELLED` | `cancelled` |
141
+ | `STREAM_ERROR`, namespaced extension codes (`acme.UPSTREAM_DOWN`) | `capability_failure` |
142
+ | `INTERNAL_ERROR`, anything else | `internal` |
143
+
144
+ ## Security
145
+
146
+ Exposing a capability through MCP does **not** bypass AppPort authorization: every
147
+ call passes AppPort validation and the application's authorizer, and handlers
148
+ receive the host-supplied session/principal. Tenant and resource isolation remain
149
+ the application's responsibility, enforced in capability handlers through that
150
+ context (for example `context.session.attributes`); a caller cannot reach
151
+ another tenant's data through MCP any more than through any other transport.
152
+
153
+ ## State
154
+
155
+ None. Nothing is cached, stored or shared between calls; a fresh SDK server is
156
+ built per HTTP request. Durable and ephemeral state (idempotency records,
157
+ sessions, operations) belong to the AppPort application.
158
+
159
+ ## Compatibility
26
160
 
27
- Tool names map to capability names (`documents.save` becomes `documents_save`)
28
- and the tool's input schema is the capability's published JSON Schema. Stream
29
- capabilities and the reserved `appport.*` namespace are excluded by default.
161
+ `createMcpBridge`, `toMcpTools`, `toToolName`, `fromToolName` and `describeError`
162
+ remain. `createMcpBridge(...).callTool(name, args, metadata?)` now forwards the
163
+ AppPort idempotency key, timeout and trace ID (previously dropped), and its
164
+ results now carry `structuredContent` and `_meta`. Prefer `createMcpHandler` /
165
+ `createMcpServer`, which speak MCP; `fromToolName` is lossy for capability names
166
+ containing `_` and is not used internally.
@@ -0,0 +1,15 @@
1
+ import type { AppPortApplication, DispatchOptions } from "@appport/core";
2
+ import { type McpBridgeOptions, type McpTool } from "./project.js";
3
+ import { type McpCallMetadata, type McpToolResult } from "./translate.js";
4
+ /**
5
+ * An in-process surface over an AppPort application, for hosts that already
6
+ * run their own MCP server. Kept for compatibility; prefer `createMcpServer` /
7
+ * `createMcpHandler`, which speak the MCP protocol.
8
+ */
9
+ export interface McpBridge {
10
+ listTools(): McpTool[];
11
+ /** `metadata` carries the AppPort idempotency key, timeout and trace ID onto the request. */
12
+ callTool(name: string, args: unknown, metadata?: McpCallMetadata): Promise<McpToolResult>;
13
+ }
14
+ export declare function createMcpBridge(application: AppPortApplication, dispatch?: DispatchOptions, options?: McpBridgeOptions): McpBridge;
15
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAgD,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExH;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,IAAI,OAAO,EAAE,CAAC;IACvB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3F;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,GAAE,eAAoB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CAgBX"}
package/dist/bridge.js ADDED
@@ -0,0 +1,26 @@
1
+ import { toMcpTools } from "./project.js";
2
+ import { readCallMetadata, toAppRequest, toToolResult } from "./translate.js";
3
+ export function createMcpBridge(application, dispatch = {}, options = {}) {
4
+ const tools = () => toMcpTools(application.manifest(), options);
5
+ return {
6
+ listTools: tools,
7
+ async callTool(name, args, metadata = {}) {
8
+ const tool = tools().find((entry) => entry.name === name);
9
+ if (!tool)
10
+ return { isError: true, content: [{ type: "text", text: `Unknown tool: ${name}` }] };
11
+ const response = await application.handleRequest(toAppRequest(tool, args, readCallMetadata(asMeta(metadata))), {
12
+ transport: "mcp",
13
+ ...dispatch
14
+ });
15
+ return toToolResult(response);
16
+ }
17
+ };
18
+ }
19
+ function asMeta(metadata) {
20
+ return {
21
+ "dev.appport/idempotencyKey": metadata.idempotencyKey,
22
+ "dev.appport/timeoutMs": metadata.timeoutMs,
23
+ "dev.appport/traceId": metadata.traceId
24
+ };
25
+ }
26
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge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C;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,59 +1,21 @@
1
1
  /**
2
- * `@appport/mcp` — expose AppPort capabilities as MCP tools (§65).
2
+ * `@appport/mcp` — the MCP adapter for AppPort (§65).
3
3
  *
4
- * The layering matters: AI → MCP → AppPort → application. AppPort does not
5
- * compete with MCP; it is the application protocol underneath it, so a
6
- * capability that is already defined, validated and authorized becomes an agent
7
- * tool without a second definition.
4
+ * AppPort is the capability and protocol authority; MCP is an external
5
+ * projection of it. Tools are derived from the application manifest, calls are
6
+ * translated into AppPort requests and dispatched through
7
+ * `AppPortApplication.handleRequest`, and results and errors are projected back.
8
+ * The protocol itself (JSON-RPC, negotiation, transports) is the official
9
+ * `@modelcontextprotocol/sdk`.
8
10
  */
9
- import { type AppPortManifest, type CapabilityManifestEntry, type JSONSchema } from "@appport/protocol";
10
- import type { AppPortApplication, DispatchOptions } from "@appport/core";
11
- /** The subset of the MCP tool descriptor AppPort can fill in from a manifest. */
12
- export interface McpTool {
13
- name: string;
14
- description: string;
15
- inputSchema: JSONSchema;
16
- /** Non-standard annotation naming the capability this tool came from. */
17
- _appport: {
18
- capability: string;
19
- version: number;
20
- authorization: string[];
21
- outputSchema: JSONSchema;
22
- };
23
- }
24
- export interface McpContent {
25
- type: "text";
26
- text: string;
27
- }
28
- export interface McpToolResult {
29
- content: McpContent[];
30
- isError?: boolean;
31
- }
32
- export interface McpBridgeOptions {
33
- /** Capability names to expose. Defaults to every request capability. */
34
- include?: (entry: CapabilityManifestEntry) => boolean;
35
- /** Prefix applied to generated tool names, e.g. `docs`. */
36
- prefix?: string;
37
- /** Expose the reserved `appport.*` capabilities. Defaults to false. */
38
- includeBuiltins?: boolean;
39
- }
40
- /** MCP tool names are conventionally `[a-z0-9_-]`; capability names are dotted. */
41
- export declare function toToolName(capability: string, prefix?: string): string;
42
- export declare function fromToolName(tool: string, prefix?: string): string;
43
- /** Renders the manifest's request capabilities as MCP tool descriptors. */
44
- export declare function toMcpTools(manifest: AppPortManifest, options?: McpBridgeOptions): McpTool[];
45
- /**
46
- * A minimal MCP server surface over an AppPort application.
47
- *
48
- * Wire `listTools` and `callTool` into an MCP server implementation; the
49
- * dispatch pipeline — validation, authorization, telemetry — is unchanged, so
50
- * an agent has exactly the access its session grants and no more.
51
- */
52
- export interface McpBridge {
53
- listTools(): McpTool[];
54
- callTool(name: string, args: unknown): Promise<McpToolResult>;
55
- }
56
- export declare function createMcpBridge(application: AppPortApplication, dispatch?: DispatchOptions, options?: McpBridgeOptions): McpBridge;
11
+ export { createMcpServer, createMcpHandler } from "./server.js";
12
+ export type { McpAuthInfo, McpCallerContext, McpCallerRequest, McpHandler, McpServerOptions } from "./server.js";
13
+ export { toMcpTools, toToolName, fromToolName } from "./project.js";
14
+ export type { McpBridgeOptions, McpTool } from "./project.js";
15
+ export { MCP_ERROR_META, MCP_META, mcpErrorCategory } from "./translate.js";
16
+ export type { McpCallMetadata, McpErrorCategory, McpToolResult } from "./translate.js";
17
+ export { createMcpBridge } from "./bridge.js";
18
+ export type { McpBridge } from "./bridge.js";
57
19
  /** Turns an AppPort error into the text an agent should see. */
58
20
  export declare function describeError(error: unknown): string;
59
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzE,iFAAiF;AACjF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,yEAAyE;IACzE,QAAQ,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CA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../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
package/dist/index.js CHANGED
@@ -1,68 +1,18 @@
1
1
  /**
2
- * `@appport/mcp` — expose AppPort capabilities as MCP tools (§65).
2
+ * `@appport/mcp` — the MCP adapter for AppPort (§65).
3
3
  *
4
- * The layering matters: AI → MCP → AppPort → application. AppPort does not
5
- * compete with MCP; it is the application protocol underneath it, so a
6
- * capability that is already defined, validated and authorized becomes an agent
7
- * tool without a second definition.
4
+ * AppPort is the capability and protocol authority; MCP is an external
5
+ * projection of it. Tools are derived from the application manifest, calls are
6
+ * translated into AppPort requests and dispatched through
7
+ * `AppPortApplication.handleRequest`, and results and errors are projected back.
8
+ * The protocol itself (JSON-RPC, negotiation, transports) is the official
9
+ * `@modelcontextprotocol/sdk`.
8
10
  */
9
- import { AppPortError, createRequest, newRequestId } from "@appport/protocol";
10
- /** MCP tool names are conventionally `[a-z0-9_-]`; capability names are dotted. */
11
- export function toToolName(capability, prefix) {
12
- const base = capability.replace(/\./g, "_");
13
- return (prefix ? `${prefix}_${base}` : base).slice(0, 64);
14
- }
15
- export function fromToolName(tool, prefix) {
16
- const withoutPrefix = prefix && tool.startsWith(`${prefix}_`) ? tool.slice(prefix.length + 1) : tool;
17
- return withoutPrefix.replace(/_/g, ".");
18
- }
19
- /** Renders the manifest's request capabilities as MCP tool descriptors. */
20
- export function toMcpTools(manifest, options = {}) {
21
- const includeBuiltins = options.includeBuiltins ?? false;
22
- return manifest.capabilities
23
- .filter((entry) => entry.kind === "request")
24
- .filter((entry) => includeBuiltins || !entry.name.startsWith("appport."))
25
- .filter((entry) => options.include?.(entry) ?? true)
26
- .map((entry) => ({
27
- name: toToolName(entry.name, options.prefix),
28
- description: entry.description ??
29
- `Invokes the ${entry.name} capability of ${manifest.application.name} (version ${entry.latestVersion}).`,
30
- inputSchema: entry.inputSchema,
31
- _appport: {
32
- capability: entry.name,
33
- version: entry.latestVersion,
34
- authorization: entry.authorization,
35
- outputSchema: entry.outputSchema
36
- }
37
- }));
38
- }
39
- export function createMcpBridge(application, dispatch = {}, options = {}) {
40
- const tools = () => toMcpTools(application.manifest(), options);
41
- return {
42
- listTools: tools,
43
- async callTool(name, args) {
44
- const tool = tools().find((entry) => entry.name === name);
45
- if (!tool) {
46
- return {
47
- isError: true,
48
- content: [{ type: "text", text: `Unknown tool: ${name}` }]
49
- };
50
- }
51
- const response = await application.handleRequest(createRequest({
52
- requestId: newRequestId(),
53
- capability: { name: tool._appport.capability, version: tool._appport.version },
54
- input: args ?? {}
55
- }), { transport: "mcp", ...dispatch });
56
- if (!response.ok) {
57
- return {
58
- isError: true,
59
- content: [{ type: "text", text: `${response.error.code}: ${response.error.message}` }]
60
- };
61
- }
62
- return { content: [{ type: "text", text: JSON.stringify(response.output, null, 2) }] };
63
- }
64
- };
65
- }
11
+ export { createMcpServer, createMcpHandler } from "./server.js";
12
+ export { toMcpTools, toToolName, fromToolName } from "./project.js";
13
+ export { MCP_ERROR_META, MCP_META, mcpErrorCategory } from "./translate.js";
14
+ export { createMcpBridge } from "./bridge.js";
15
+ import { AppPortError } from "@appport/protocol";
66
16
  /** Turns an AppPort error into the text an agent should see. */
67
17
  export function describeError(error) {
68
18
  return AppPortError.is(error) ? `${error.code}: ${error.message}` : "INTERNAL_ERROR: the capability failed";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EAIb,MAAM,mBAAmB,CAAC;AA+B3B,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,UAAkB,EAAE,MAAe;IAC5D,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5C,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAe;IACxD,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrG,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAC,QAAyB,EAAE,UAA4B,EAAE;IAClF,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,KAAK,CAAC;IACzD,OAAO,QAAQ,CAAC,YAAY;SACzB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,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AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAShE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,gEAAgE;AAChE,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,uCAAuC,CAAC;AAC9G,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type AppPortManifest, type AuthorizationRequirement, type CapabilityEffect, type CapabilityIntegration, type CapabilityManifestEntry, type IdempotencySupport, type JSONSchema } from "@appport/protocol";
2
+ /**
3
+ * Projection of AppPort capabilities onto MCP tools.
4
+ *
5
+ * The manifest is the only source: a tool exists because a request capability
6
+ * exists in the manifest, its `inputSchema` is the capability's published schema,
7
+ * and nothing here keeps a list of its own.
8
+ */
9
+ /** The subset of the MCP tool descriptor AppPort can fill in from a manifest. */
10
+ export interface McpTool {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: JSONSchema;
14
+ /** Non-standard annotation naming the capability this tool came from. */
15
+ _appport: {
16
+ capability: string;
17
+ version: number;
18
+ authorization: string[];
19
+ outputSchema: JSONSchema;
20
+ /** Whether the capability only observes state or may change it. Absent only if the manifest omits it. */
21
+ effect?: CapabilityEffect;
22
+ idempotency?: IdempotencySupport;
23
+ emits?: string[];
24
+ authorizationContract?: AuthorizationRequirement;
25
+ /** Published purpose, authority and declared effects (`appport.integration/1`). */
26
+ integration?: CapabilityIntegration;
27
+ };
28
+ }
29
+ export interface McpBridgeOptions {
30
+ /** Capability names to expose. Defaults to every request capability. */
31
+ include?: (entry: CapabilityManifestEntry) => boolean;
32
+ /** Prefix applied to generated tool names, e.g. `docs`. */
33
+ prefix?: string;
34
+ /** Expose the reserved `appport.*` capabilities. Defaults to false. */
35
+ includeBuiltins?: boolean;
36
+ }
37
+ /**
38
+ * Deterministic capability → tool name projection: `.` becomes `_`, then the
39
+ * optional prefix is applied. The tool name is a derived label, never an
40
+ * identity — {@link toMcpTools} resolves calls through the manifest, not by
41
+ * reversing this function.
42
+ */
43
+ export declare function toToolName(capability: string, prefix?: string): string;
44
+ /**
45
+ * Best-effort inverse of {@link toToolName}. Lossy for capability names that
46
+ * contain `_`; prefer {@link toMcpTools}, which records the exact capability.
47
+ */
48
+ export declare function fromToolName(tool: string, prefix?: string): string;
49
+ /**
50
+ * Renders the manifest's request capabilities as MCP tool descriptors.
51
+ *
52
+ * Stream capabilities and capabilities whose input is not an object schema
53
+ * (MCP tool input must be an object) are omitted. Two capabilities that project
54
+ * to the same tool name are an error, never a silent overwrite.
55
+ */
56
+ export declare function toMcpTools(manifest: AppPortManifest, options?: McpBridgeOptions): McpTool[];
57
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AAEH,iFAAiF;AACjF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,yEAAyE;IACzE,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,YAAY,EAAE,UAAU,CAAC;QACzB,yGAAyG;QACzG,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,WAAW,CAAC,EAAE,kBAAkB,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,qBAAqB,CAAC,EAAE,wBAAwB,CAAC;QACjD,mFAAmF;QACnF,WAAW,CAAC,EAAE,qBAAqB,CAAC;KACrC,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,OAAO,CAAC;IACtD,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGtE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,EAAE,CA0C/F"}
@@ -0,0 +1,66 @@
1
+ import { getIntegration, integrationKey } from "@appport/protocol";
2
+ /**
3
+ * Deterministic capability → tool name projection: `.` becomes `_`, then the
4
+ * optional prefix is applied. The tool name is a derived label, never an
5
+ * identity — {@link toMcpTools} resolves calls through the manifest, not by
6
+ * reversing this function.
7
+ */
8
+ export function toToolName(capability, prefix) {
9
+ const base = capability.replace(/\./g, "_");
10
+ return (prefix ? `${prefix}_${base}` : base).slice(0, 64);
11
+ }
12
+ /**
13
+ * Best-effort inverse of {@link toToolName}. Lossy for capability names that
14
+ * contain `_`; prefer {@link toMcpTools}, which records the exact capability.
15
+ */
16
+ export function fromToolName(tool, prefix) {
17
+ const withoutPrefix = prefix && tool.startsWith(`${prefix}_`) ? tool.slice(prefix.length + 1) : tool;
18
+ return withoutPrefix.replace(/_/g, ".");
19
+ }
20
+ /**
21
+ * Renders the manifest's request capabilities as MCP tool descriptors.
22
+ *
23
+ * Stream capabilities and capabilities whose input is not an object schema
24
+ * (MCP tool input must be an object) are omitted. Two capabilities that project
25
+ * to the same tool name are an error, never a silent overwrite.
26
+ */
27
+ export function toMcpTools(manifest, options = {}) {
28
+ const includeBuiltins = options.includeBuiltins ?? false;
29
+ const tools = manifest.capabilities
30
+ .filter((entry) => entry.kind === "request")
31
+ .filter((entry) => includeBuiltins || !entry.name.startsWith("appport."))
32
+ .filter((entry) => entry.inputSchema.type === "object")
33
+ .filter((entry) => options.include?.(entry) ?? true)
34
+ .map((entry) => {
35
+ const version = entry.definitions.find((definition) => definition.version === entry.latestVersion);
36
+ const integration = getIntegration(manifest)?.capabilities[integrationKey(entry.name, entry.latestVersion)];
37
+ return { entry, version, integration };
38
+ })
39
+ .map(({ entry, version, integration }) => ({
40
+ name: toToolName(entry.name, options.prefix),
41
+ description: entry.description ??
42
+ `Invokes the ${entry.name} capability of ${manifest.application.name} (version ${entry.latestVersion}).`,
43
+ inputSchema: entry.inputSchema,
44
+ _appport: {
45
+ capability: entry.name,
46
+ version: entry.latestVersion,
47
+ authorization: entry.authorization,
48
+ outputSchema: entry.outputSchema,
49
+ ...(entry.effect ? { effect: entry.effect } : {}),
50
+ ...(entry.idempotency ? { idempotency: entry.idempotency } : {}),
51
+ ...(version?.emits?.length ? { emits: [...version.emits] } : {}),
52
+ ...(entry.authorizationContract ? { authorizationContract: entry.authorizationContract } : {}),
53
+ ...(integration ? { integration } : {})
54
+ }
55
+ }));
56
+ const seen = new Map();
57
+ for (const tool of tools) {
58
+ const previous = seen.get(tool.name);
59
+ if (previous !== undefined) {
60
+ throw new Error(`MCP tool name collision: capabilities "${previous}" and "${tool._appport.capability}" both project to "${tool.name}"`);
61
+ }
62
+ seen.set(tool.name, tool._appport.capability);
63
+ }
64
+ return tools;
65
+ }
66
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EAQf,MAAM,mBAAmB,CAAC;AAwC3B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,UAAkB,EAAE,MAAe;IAC5D,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5C,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAe;IACxD,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrG,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,QAAyB,EAAE,UAA4B,EAAE;IAClF,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,KAAK,CAAC;IACzD,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY;SAChC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;SAC3C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,C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AAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9F,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC;KACF,CAAC,CAAC,CAAC;IAEN,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,0CAA0C,QAAQ,UAAU,IAAI,CAAC,QAAQ,CAAC,UAAU,sBAAsB,IAAI,CAAC,IAAI,GAAG,CACvH,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { AppPortApplication } from "@appport/core";
2
+ import type { Principal, Session } from "@appport/protocol";
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
+ import { type McpBridgeOptions } from "./project.js";
5
+ /** Bearer/OAuth information the host verified for the current MCP request. */
6
+ export interface McpAuthInfo {
7
+ token: string;
8
+ clientId: string;
9
+ scopes: string[];
10
+ expiresAt?: number;
11
+ extra?: Record<string, unknown>;
12
+ }
13
+ /** What the adapter knows about the HTTP request or connection behind an MCP call. */
14
+ export interface McpCallerRequest {
15
+ /** Present when the host passed verified auth info to the handler. */
16
+ authInfo?: McpAuthInfo;
17
+ /** Request headers when the transport carried an HTTP request; empty otherwise. */
18
+ headers: Readonly<Record<string, string | string[] | undefined>>;
19
+ }
20
+ /**
21
+ * The caller identity AppPort authorizes against: exactly the `session` /
22
+ * `principal` a native transport would supply in `DispatchOptions`.
23
+ */
24
+ export interface McpCallerContext {
25
+ session?: Session;
26
+ principal?: Principal;
27
+ }
28
+ export interface McpServerOptions extends McpBridgeOptions {
29
+ /** `serverInfo` for MCP initialization. Defaults to the application's name and version. */
30
+ serverInfo?: {
31
+ name: string;
32
+ version: string;
33
+ };
34
+ /**
35
+ * Establishes the authenticated caller for one MCP request.
36
+ *
37
+ * The host verifies credentials (the adapter never does) and returns the
38
+ * AppPort session/principal they map to. Returning nothing dispatches the
39
+ * call anonymously, which AppPort's authorizer rejects for any capability
40
+ * that requires permissions. Throw an `AppPortError` (`UNAUTHORIZED`,
41
+ * `FORBIDDEN`) to refuse the call; it is reported as a tool error.
42
+ */
43
+ context?: (request: McpCallerRequest) => McpCallerContext | undefined | Promise<McpCallerContext | undefined>;
44
+ }
45
+ /**
46
+ * Creates an MCP `Server` (official SDK) over an AppPort application.
47
+ *
48
+ * The server owns no capability, session or request state; every call is
49
+ * translated into an AppPort request and dispatched through
50
+ * `application.handleRequest`. Connect it to any SDK transport
51
+ * (`InMemoryTransport`, stdio, …). For HTTP hosting use {@link createMcpHandler}.
52
+ */
53
+ export declare function createMcpServer(application: AppPortApplication, options?: McpServerOptions): Server;
54
+ /** A WHATWG fetch handler serving the MCP Streamable HTTP protocol. */
55
+ export type McpHandler = (request: Request, host?: {
56
+ authInfo?: McpAuthInfo;
57
+ }) => Promise<Response>;
58
+ /**
59
+ * Serves MCP over Streamable HTTP as a `(Request) => Promise<Response>`
60
+ * function, usable from any route handler, Workers, Deno, Bun or a
61
+ * Node adapter.
62
+ *
63
+ * It is stateless: each HTTP request gets its own `Server` and transport,
64
+ * answered as a single JSON response and then closed, so nothing survives
65
+ * between requests and no long-lived process or sticky routing is needed.
66
+ * The host owns routing, TLS, credential verification and origin checks; it
67
+ * may pass verified `authInfo` as the second argument and/or read headers in
68
+ * `options.context`.
69
+ */
70
+ export declare function createMcpHandler(application: AppPortApplication, options?: McpServerOptions): McpHandler;
71
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAc,KAAK,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAS/E,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,mFAAmF;IACnF,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;CAClE;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,2FAA2F;IAC3F,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;CAC/G;AAqFD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,kBAAkB,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAEvG;AAED,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEpG;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,EAAE,OAAO,GAAE,gBAAqB,GAAG,UAAU,CAoB5G"}
package/dist/server.js ADDED
@@ -0,0 +1,125 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
3
+ import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError } from "@modelcontextprotocol/sdk/types.js";
4
+ import { toMcpTools } from "./project.js";
5
+ import { readCallMetadata, toAdapterErrorResult, toAppRequest, toToolResult } from "./translate.js";
6
+ function internalFailure(application, error, where) {
7
+ application.logger.error("mcp adapter failure", { where, error: error instanceof Error ? error.name : "unknown" });
8
+ return new McpError(ErrorCode.InternalError, "Internal error");
9
+ }
10
+ /** Wire descriptor for a projected tool. The AppPort capability rides in `_meta`. */
11
+ function describeTool(tool) {
12
+ const output = tool._appport.outputSchema;
13
+ return {
14
+ name: tool.name,
15
+ description: tool.description,
16
+ inputSchema: tool.inputSchema,
17
+ ...(output.type === "object" ? { outputSchema: tool._appport.outputSchema } : {}),
18
+ _meta: {
19
+ "dev.appport/capability": {
20
+ name: tool._appport.capability,
21
+ version: tool._appport.version,
22
+ authorization: tool._appport.authorization,
23
+ ...(tool._appport.effect ? { effect: tool._appport.effect } : {}),
24
+ ...(tool._appport.idempotency ? { idempotency: tool._appport.idempotency } : {}),
25
+ ...(tool._appport.emits ? { emits: tool._appport.emits } : {}),
26
+ ...(tool._appport.authorizationContract ? { authorizationContract: tool._appport.authorizationContract } : {}),
27
+ ...(tool._appport.integration ? { integration: tool._appport.integration } : {})
28
+ }
29
+ }
30
+ };
31
+ }
32
+ function build(application, options, hostSignal) {
33
+ const { serverInfo, context, ...projection } = options;
34
+ const manifest = application.manifest();
35
+ const server = new Server(serverInfo ?? { name: manifest.application.name, version: manifest.application.version }, { capabilities: { tools: { listChanged: false } } });
36
+ toMcpTools(manifest, projection); // fail at construction on a name collision, not on first use
37
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
38
+ try {
39
+ return { tools: toMcpTools(application.manifest(), projection).map(describeTool) };
40
+ }
41
+ catch (error) {
42
+ throw internalFailure(application, error, "tools/list");
43
+ }
44
+ });
45
+ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
46
+ const tools = (() => {
47
+ try {
48
+ return toMcpTools(application.manifest(), projection);
49
+ }
50
+ catch (error) {
51
+ throw internalFailure(application, error, "tools/call");
52
+ }
53
+ })();
54
+ const tool = tools.find((entry) => entry.name === request.params.name);
55
+ if (!tool)
56
+ throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${request.params.name}`);
57
+ try {
58
+ const metadata = readCallMetadata(request.params._meta);
59
+ const caller = context
60
+ ? await context({
61
+ ...(extra.authInfo ? { authInfo: extra.authInfo } : {}),
62
+ headers: (extra.requestInfo?.headers ?? {})
63
+ })
64
+ : undefined;
65
+ const signal = hostSignal ? AbortSignal.any([extra.signal, hostSignal]) : extra.signal;
66
+ const response = await application.handleRequest(toAppRequest(tool, request.params.arguments, metadata), {
67
+ transport: "mcp",
68
+ signal,
69
+ ...(caller?.session ? { session: caller.session } : {}),
70
+ ...(caller?.principal ? { principal: caller.principal } : {})
71
+ });
72
+ return toToolResult(response);
73
+ }
74
+ catch (error) {
75
+ const result = toAdapterErrorResult(error);
76
+ if (result)
77
+ return result;
78
+ throw internalFailure(application, error, "tools/call");
79
+ }
80
+ });
81
+ return server;
82
+ }
83
+ /**
84
+ * Creates an MCP `Server` (official SDK) over an AppPort application.
85
+ *
86
+ * The server owns no capability, session or request state; every call is
87
+ * translated into an AppPort request and dispatched through
88
+ * `application.handleRequest`. Connect it to any SDK transport
89
+ * (`InMemoryTransport`, stdio, …). For HTTP hosting use {@link createMcpHandler}.
90
+ */
91
+ export function createMcpServer(application, options = {}) {
92
+ return build(application, options);
93
+ }
94
+ /**
95
+ * Serves MCP over Streamable HTTP as a `(Request) => Promise<Response>`
96
+ * function, usable from any route handler, Workers, Deno, Bun or a
97
+ * Node adapter.
98
+ *
99
+ * It is stateless: each HTTP request gets its own `Server` and transport,
100
+ * answered as a single JSON response and then closed, so nothing survives
101
+ * between requests and no long-lived process or sticky routing is needed.
102
+ * The host owns routing, TLS, credential verification and origin checks; it
103
+ * may pass verified `authInfo` as the second argument and/or read headers in
104
+ * `options.context`.
105
+ */
106
+ export function createMcpHandler(application, options = {}) {
107
+ build(application, options); // validate the projection once, up front
108
+ return async (request, host = {}) => {
109
+ // Stateless: there are no sessions to resume or server-initiated streams to hold open, so
110
+ // the optional GET (SSE) and DELETE (session end) endpoints are declined, as MCP permits.
111
+ if (request.method !== "POST") {
112
+ return Response.json({ jsonrpc: "2.0", error: { code: -32000, message: "Method not allowed." }, id: null }, { status: 405, headers: { allow: "POST" } });
113
+ }
114
+ const server = build(application, options, request.signal);
115
+ const transport = new WebStandardStreamableHTTPServerTransport({ enableJsonResponse: true });
116
+ await server.connect(transport);
117
+ try {
118
+ return await transport.handleRequest(request, host.authInfo ? { authInfo: host.authInfo } : {});
119
+ }
120
+ finally {
121
+ await server.close();
122
+ }
123
+ };
124
+ }
125
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,wCAAwC,EAAE,MAAM,+DAA+D,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACxH,OAAO,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EAEb,MAAM,gBAAgB,CAAC;AA2CxB,SAAS,eAAe,CAAC,WAA+B,EAAE,KAAc,EAAE,KAAa;IACrF,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IACnH,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AACjE,CAAC;AAED,qFAAqF;AACrF,SAAS,YAAY,CAAC,IAAa;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAkC,CAAC;IAChE,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAyD;QAC3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AC7F,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClG,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type AppErrorObject, type AppRequest, type AppResponse } from "@appport/protocol";
2
+ import type { McpTool } from "./project.js";
3
+ /**
4
+ * `_meta` keys on an MCP `tools/call` request that map onto AppPort request
5
+ * fields. They carry the same values as `AppRequest.idempotencyKey`,
6
+ * `timeoutMs` and `traceId`; MCP defines no metadata of its own for them.
7
+ */
8
+ export declare const MCP_META: {
9
+ readonly idempotencyKey: "dev.appport/idempotencyKey";
10
+ readonly timeoutMs: "dev.appport/timeoutMs";
11
+ readonly traceId: "dev.appport/traceId";
12
+ };
13
+ /** The `_meta` key on a tool result carrying the AppPort error object's code and category. */
14
+ export declare const MCP_ERROR_META = "dev.appport/error";
15
+ /** AppPort request metadata carried by an MCP call. */
16
+ export interface McpCallMetadata {
17
+ idempotencyKey?: string;
18
+ timeoutMs?: number;
19
+ traceId?: string;
20
+ }
21
+ /** Reads AppPort request metadata out of an MCP `_meta` object, rejecting malformed values. */
22
+ export declare function readCallMetadata(meta: unknown): McpCallMetadata;
23
+ /** Builds the canonical AppPort request for an MCP tool call. Nothing is cached or defaulted here. */
24
+ export declare function toAppRequest(tool: McpTool, args: unknown, metadata?: McpCallMetadata): AppRequest;
25
+ export type McpErrorCategory = "invalid_request" | "unauthenticated" | "forbidden" | "not_found" | "conflict" | "timeout" | "rate_limited" | "cancelled" | "capability_failure" | "internal";
26
+ /**
27
+ * The single AppPort error code → MCP outcome category mapping. Extension
28
+ * codes (`vendor.CODE`) are capability-defined failures and map to
29
+ * `capability_failure`; anything unrecognised is `internal`.
30
+ */
31
+ export declare function mcpErrorCategory(code: string): McpErrorCategory;
32
+ export interface McpToolResult {
33
+ content: {
34
+ type: "text";
35
+ text: string;
36
+ }[];
37
+ structuredContent?: Record<string, unknown>;
38
+ isError?: boolean;
39
+ _meta?: Record<string, unknown>;
40
+ }
41
+ /**
42
+ * Projects an AppPort response onto an MCP tool result.
43
+ *
44
+ * Failures are tool execution errors (`isError: true`), which MCP defines for
45
+ * failures an agent can act on; the AppPort code, category, retryability and
46
+ * sanitized details ride in `_meta` so they are never flattened into a
47
+ * successful result. The error object is already sanitized by AppPort (§16).
48
+ */
49
+ export declare function toToolResult(response: AppResponse): McpToolResult;
50
+ export declare function toErrorResult(error: AppErrorObject, traceId?: string): McpToolResult;
51
+ /** Sanitized error for a failure raised by the adapter itself, before dispatch. */
52
+ export declare function toAdapterErrorResult(error: unknown): McpToolResult | undefined;
53
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAEX,8FAA8F;AAC9F,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAElD,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAwB/D;AAED,sGAAsG;AACtG,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAE,eAAoB,GAAG,UAAU,CASrG;AAED,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,UAAU,GACV,SAAS,GACT,cAAc,GACd,WAAW,GACX,oBAAoB,GACpB,UAAU,CAAC;AAsBf;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAI/D;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAMD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,aAAa,CAUjE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,CAepF;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAE9E"}
@@ -0,0 +1,126 @@
1
+ import { AppPortError, createRequest, errors, newRequestId } from "@appport/protocol";
2
+ /**
3
+ * `_meta` keys on an MCP `tools/call` request that map onto AppPort request
4
+ * fields. They carry the same values as `AppRequest.idempotencyKey`,
5
+ * `timeoutMs` and `traceId`; MCP defines no metadata of its own for them.
6
+ */
7
+ export const MCP_META = {
8
+ idempotencyKey: "dev.appport/idempotencyKey",
9
+ timeoutMs: "dev.appport/timeoutMs",
10
+ traceId: "dev.appport/traceId"
11
+ };
12
+ /** The `_meta` key on a tool result carrying the AppPort error object's code and category. */
13
+ export const MCP_ERROR_META = "dev.appport/error";
14
+ /** Reads AppPort request metadata out of an MCP `_meta` object, rejecting malformed values. */
15
+ export function readCallMetadata(meta) {
16
+ if (meta === undefined || meta === null)
17
+ return {};
18
+ if (typeof meta !== "object" || Array.isArray(meta))
19
+ throw errors.invalidRequest("_meta must be an object");
20
+ const record = meta;
21
+ const out = {};
22
+ const key = record[MCP_META.idempotencyKey];
23
+ if (key !== undefined) {
24
+ if (typeof key !== "string" || key.length === 0)
25
+ throw errors.invalidRequest("idempotencyKey must be a non-empty string");
26
+ out.idempotencyKey = key;
27
+ }
28
+ const timeout = record[MCP_META.timeoutMs];
29
+ if (timeout !== undefined) {
30
+ if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout <= 0) {
31
+ throw errors.invalidRequest("timeoutMs must be a positive number");
32
+ }
33
+ out.timeoutMs = timeout;
34
+ }
35
+ const trace = record[MCP_META.traceId];
36
+ if (trace !== undefined) {
37
+ if (typeof trace !== "string" || trace.length === 0)
38
+ throw errors.invalidRequest("traceId must be a non-empty string");
39
+ out.traceId = trace;
40
+ }
41
+ return out;
42
+ }
43
+ /** Builds the canonical AppPort request for an MCP tool call. Nothing is cached or defaulted here. */
44
+ export function toAppRequest(tool, args, metadata = {}) {
45
+ return createRequest({
46
+ requestId: newRequestId(),
47
+ capability: { name: tool._appport.capability, version: tool._appport.version },
48
+ input: args ?? {},
49
+ ...(metadata.idempotencyKey !== undefined ? { idempotencyKey: metadata.idempotencyKey } : {}),
50
+ ...(metadata.timeoutMs !== undefined ? { timeoutMs: metadata.timeoutMs } : {}),
51
+ ...(metadata.traceId !== undefined ? { traceId: metadata.traceId } : {})
52
+ });
53
+ }
54
+ const CATEGORY = {
55
+ INVALID_PROTOCOL: "invalid_request",
56
+ UNSUPPORTED_VERSION: "invalid_request",
57
+ INVALID_REQUEST: "invalid_request",
58
+ INVALID_INPUT: "invalid_request",
59
+ UNSUPPORTED_CAPABILITY_VERSION: "invalid_request",
60
+ NO_COMPATIBLE_MATERIALIZATION: "invalid_request",
61
+ PAYLOAD_TOO_LARGE: "invalid_request",
62
+ UNAUTHORIZED: "unauthenticated",
63
+ FORBIDDEN: "forbidden",
64
+ NOT_FOUND: "not_found",
65
+ UNKNOWN_CAPABILITY: "not_found",
66
+ CONFLICT: "conflict",
67
+ TIMEOUT: "timeout",
68
+ RATE_LIMITED: "rate_limited",
69
+ CANCELLED: "cancelled",
70
+ STREAM_ERROR: "capability_failure",
71
+ INTERNAL_ERROR: "internal"
72
+ };
73
+ /**
74
+ * The single AppPort error code → MCP outcome category mapping. Extension
75
+ * codes (`vendor.CODE`) are capability-defined failures and map to
76
+ * `capability_failure`; anything unrecognised is `internal`.
77
+ */
78
+ export function mcpErrorCategory(code) {
79
+ const known = CATEGORY[code];
80
+ if (known)
81
+ return known;
82
+ return /^[a-z][a-z0-9]*(\.[a-z0-9]+)*\.[A-Z][A-Z0-9_]*$/.test(code) ? "capability_failure" : "internal";
83
+ }
84
+ function isPlainObject(value) {
85
+ return typeof value === "object" && value !== null && !Array.isArray(value);
86
+ }
87
+ /**
88
+ * Projects an AppPort response onto an MCP tool result.
89
+ *
90
+ * Failures are tool execution errors (`isError: true`), which MCP defines for
91
+ * failures an agent can act on; the AppPort code, category, retryability and
92
+ * sanitized details ride in `_meta` so they are never flattened into a
93
+ * successful result. The error object is already sanitized by AppPort (§16).
94
+ */
95
+ export function toToolResult(response) {
96
+ const trace = response.traceId ? { [MCP_META.traceId]: response.traceId } : {};
97
+ if (response.ok) {
98
+ return {
99
+ content: [{ type: "text", text: JSON.stringify(response.output ?? null) }],
100
+ ...(isPlainObject(response.output) ? { structuredContent: response.output } : {}),
101
+ ...(Object.keys(trace).length ? { _meta: trace } : {})
102
+ };
103
+ }
104
+ return toErrorResult(response.error, response.traceId);
105
+ }
106
+ export function toErrorResult(error, traceId) {
107
+ const category = mcpErrorCategory(error.code);
108
+ return {
109
+ isError: true,
110
+ content: [{ type: "text", text: `${error.code}: ${error.message}` }],
111
+ _meta: {
112
+ [MCP_ERROR_META]: {
113
+ code: error.code,
114
+ category,
115
+ retryable: error.retryable ?? false,
116
+ ...(error.details !== undefined ? { details: error.details } : {})
117
+ },
118
+ ...(traceId ? { [MCP_META.traceId]: traceId } : {})
119
+ }
120
+ };
121
+ }
122
+ /** Sanitized error for a failure raised by the adapter itself, before dispatch. */
123
+ export function toAdapterErrorResult(error) {
124
+ return AppPortError.is(error) ? toErrorResult(error.toErrorObject()) : undefined;
125
+ }
126
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,YAAY,EAKb,MAAM,mBAAmB,CAAC;AAG3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,cAAc,EAAE,4BAA4B;IAC5C,SAAS,EAAE,uBAAuB;IAClC,OAAO,EAAE,qBAAqB;CACtB,CAAC;AAEX,8FAA8F;AAC9F,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AASlD,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACnD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,MAAM,MAAM,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC;IAC5G,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,GAAG,GAAoB,EAAE,CAAC;IAEhC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,OAAO,GAAG,K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,IAAI;gBAChB,QAAQ;gBACR,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,KAAK;gBACnC,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChF;YACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD;KACF,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@appport/mcp",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Expose AppPort capabilities as MCP tools.",
5
5
  "license": "Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/rkendel1/appport.git", "directory": "packages/mcp" },
6
+ "engines": { "node": ">=20" },
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rkendel1/appport.git",
10
+ "directory": "packages/mcp"
11
+ },
7
12
  "type": "module",
8
13
  "main": "./dist/index.js",
9
14
  "types": "./dist/index.d.ts",
@@ -22,8 +27,11 @@
22
27
  "clean": "tsc -b --clean"
23
28
  },
24
29
  "dependencies": {
25
- "@appport/protocol": "1.0.2",
26
- "@appport/core": "1.0.3"
30
+ "@appport/core": "1.1.0",
31
+ "@appport/protocol": "1.1.0",
32
+ "@modelcontextprotocol/sdk": "^1.31.0"
27
33
  },
28
- "publishConfig": { "access": "public" }
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
29
37
  }