@solvapay/mcp-core 0.1.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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SolvaPay Inc.
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
+ # @solvapay/mcp-core
2
+
3
+ Framework-neutral MCP (Model Context Protocol) contracts for the SolvaPay SDK.
4
+
5
+ This package owns the shapes that cross the SolvaPay server ↔ client ↔
6
+ adapter boundary: tool names, descriptor builder, paywall `_meta.ui`
7
+ envelope, Stripe CSP baseline, bootstrap payload, pure OAuth discovery
8
+ JSON builders, JWT bearer helpers.
9
+
10
+ It does **not** depend on `@modelcontextprotocol/sdk`,
11
+ `@modelcontextprotocol/ext-apps`, or any runtime-specific HTTP plumbing.
12
+ The official `@modelcontextprotocol/*` adapter lives in
13
+ [`@solvapay/mcp`](../mcp); Node `(req, res, next)` OAuth middleware lives
14
+ in [`@solvapay/mcp-express`](../mcp-express); fetch-first OAuth + the
15
+ turnkey handler lives in [`@solvapay/mcp-fetch`](../mcp-fetch).
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add @solvapay/mcp-core @solvapay/server
21
+ ```
22
+
23
+ ## What's in the box
24
+
25
+ | Export | Use when |
26
+ |---|---|
27
+ | `MCP_TOOL_NAMES`, `McpToolName` | You're implementing a SolvaPay MCP transport tool on any framework and need the canonical tool names |
28
+ | `buildSolvaPayDescriptors(opts)` | You're writing an MCP adapter (`fastmcp`, raw JSON-RPC) and want the full SolvaPay tool surface as descriptor objects |
29
+ | `buildPayableHandler(solvaPay, ctx, handler)` | You're hand-rolling a paywall-protected tool and need the `_meta.ui` envelope auto-attached on paywall results |
30
+ | `paywallToolResult(errOrGate, ctx)` | You have a `PaywallError` (legacy `try/catch`) or a `PaywallStructuredContent` gate from `paywall.decide()` and want to return it with the right `_meta.ui` + `BootstrapPayload` |
31
+ | `buildPaywallUiMeta({ resourceUri, toolName })` | You're building the `_meta.ui` envelope yourself |
32
+ | `SOLVAPAY_DEFAULT_CSP`, `mergeCsp(overrides)` | You're registering the SolvaPay UI resource and want the Stripe allow-list baked in |
33
+ | `getOAuthAuthorizationServerResponse(opts)`, `getOAuthProtectedResourceResponse(url)` | You're serving the `.well-known/*` discovery JSON from any runtime |
34
+ | `buildAuthInfoFromBearer(header, opts)` | You're plugging a raw `Authorization: Bearer …` header into an MCP `authInfo` envelope |
35
+ | `McpBearerAuthError`, `extractBearerToken`, `decodeJwtPayload`, `getCustomerRefFromJwtPayload`, `getCustomerRefFromBearerAuthHeader` | Low-level JWT bearer parsing — no signature verification (validate upstream first) |
36
+
37
+ ## Typical usage
38
+
39
+ If you're starting a new SolvaPay MCP server on the official
40
+ `@modelcontextprotocol/sdk`, don't use this package directly — use
41
+ [`@solvapay/mcp`](../mcp), which wraps it with one-call ergonomics.
42
+
43
+ If you need HTTP-level OAuth handlers, pair this package with either
44
+ [`@solvapay/mcp-express`](../mcp-express) (Node) or
45
+ [`@solvapay/mcp-fetch`](../mcp-fetch) (Deno / Supabase Edge / Cloudflare
46
+ Workers / Bun / Next edge).
47
+
48
+ If you're writing a new adapter (fastmcp, custom JSON-RPC):
49
+
50
+ ```ts
51
+ import { buildSolvaPayDescriptors } from '@solvapay/mcp-core'
52
+
53
+ const { tools, resource } = buildSolvaPayDescriptors({
54
+ solvaPay,
55
+ productRef: 'prd_video',
56
+ resourceUri: 'ui://my-app/mcp-app.html',
57
+ readHtml: async () => readFileSync('./dist/mcp-app.html', 'utf-8'),
58
+ publicBaseUrl: 'https://my-app.example.com',
59
+ })
60
+
61
+ for (const tool of tools) {
62
+ myAdapter.registerTool(tool.name, tool)
63
+ }
64
+ myAdapter.registerResource(resource)
65
+ ```
66
+
67
+ ## Peer dependencies
68
+
69
+ | Peer | Why | Optional? |
70
+ |---|---|---|
71
+ | `@solvapay/server` | Runtime `*Core` helpers + `SolvaPay`, `PaywallError`, `PaywallStructuredContent` types | Yes — only consumed by `buildSolvaPayDescriptors`, `buildPayableHandler`, `paywallToolResult` |
72
+ | `zod` | Descriptor `inputSchema` shape | Yes — descriptor consumers decide whether to use zod |
73
+
74
+ ## See also
75
+
76
+ - [`@solvapay/mcp`](../mcp) — official `@modelcontextprotocol/sdk` + `ext-apps` adapter (`createSolvaPayMcpServer`)
77
+ - [`@solvapay/mcp-express`](../mcp-express) — Node `(req, res, next)` OAuth middleware stack
78
+ - [`@solvapay/mcp-fetch`](../mcp-fetch) — fetch-first OAuth handlers + turnkey `createSolvaPayMcpFetchHandler`
79
+ - [`@solvapay/server`](../server) — core SDK (paywall, webhooks, `*Core` helpers)
80
+ - [`@solvapay/react/mcp`](../react) — React provider + views for the MCP App UI shell