@civic/x402-mcp 0.0.1
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/.claude/settings.local.json +26 -0
- package/.env.example +10 -0
- package/.github/workflows/ci.yml +144 -0
- package/.github/workflows/release.yml +56 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/x402-mcp-example.iml +13 -0
- package/CLAUDE.md +31 -0
- package/DEVELOPER.md +181 -0
- package/README.md +274 -0
- package/biome.json +63 -0
- package/dist/example/client/client.d.ts +3 -0
- package/dist/example/client/client.d.ts.map +1 -0
- package/dist/example/client/client.js +93 -0
- package/dist/example/client/client.js.map +1 -0
- package/dist/example/client.d.ts +3 -0
- package/dist/example/client.d.ts.map +1 -0
- package/dist/example/client.js +105 -0
- package/dist/example/client.js.map +1 -0
- package/dist/example/config.d.ts +15 -0
- package/dist/example/config.d.ts.map +1 -0
- package/dist/example/config.js +20 -0
- package/dist/example/config.js.map +1 -0
- package/dist/example/proxy/client-proxy.d.ts +3 -0
- package/dist/example/proxy/client-proxy.d.ts.map +1 -0
- package/dist/example/proxy/client-proxy.js +88 -0
- package/dist/example/proxy/client-proxy.js.map +1 -0
- package/dist/example/proxy/client.d.ts +3 -0
- package/dist/example/proxy/client.d.ts.map +1 -0
- package/dist/example/proxy/client.js +97 -0
- package/dist/example/proxy/client.js.map +1 -0
- package/dist/example/proxy/server-proxy.d.ts +3 -0
- package/dist/example/proxy/server-proxy.d.ts.map +1 -0
- package/dist/example/proxy/server-proxy.js +72 -0
- package/dist/example/proxy/server-proxy.js.map +1 -0
- package/dist/example/server.d.ts +2 -0
- package/dist/example/server.d.ts.map +1 -0
- package/dist/example/server.js +76 -0
- package/dist/example/server.js.map +1 -0
- package/dist/example/service.d.ts +4 -0
- package/dist/example/service.d.ts.map +1 -0
- package/dist/example/service.js +15 -0
- package/dist/example/service.js.map +1 -0
- package/dist/scripts/analyzePayment.d.ts +3 -0
- package/dist/scripts/analyzePayment.d.ts.map +1 -0
- package/dist/scripts/analyzePayment.js +25 -0
- package/dist/scripts/analyzePayment.js.map +1 -0
- package/dist/scripts/client-proxy.d.ts +3 -0
- package/dist/scripts/client-proxy.d.ts.map +1 -0
- package/dist/scripts/client-proxy.js +126 -0
- package/dist/scripts/client-proxy.js.map +1 -0
- package/dist/scripts/generateWallet.d.ts +3 -0
- package/dist/scripts/generateWallet.d.ts.map +1 -0
- package/dist/scripts/generateWallet.js +15 -0
- package/dist/scripts/generateWallet.js.map +1 -0
- package/dist/src/client.d.ts +11 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +52 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/client.test.d.ts +2 -0
- package/dist/src/client.test.d.ts.map +1 -0
- package/dist/src/client.test.js +178 -0
- package/dist/src/client.test.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +2 -0
- package/dist/src/index.test.d.ts.map +1 -0
- package/dist/src/index.test.js +27 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/mcpClientWithX402.d.ts +14 -0
- package/dist/src/mcpClientWithX402.d.ts.map +1 -0
- package/dist/src/mcpClientWithX402.js +78 -0
- package/dist/src/mcpClientWithX402.js.map +1 -0
- package/dist/src/proxy/client.d.ts +23 -0
- package/dist/src/proxy/client.d.ts.map +1 -0
- package/dist/src/proxy/client.js +39 -0
- package/dist/src/proxy/client.js.map +1 -0
- package/dist/src/proxy/client.test.d.ts +2 -0
- package/dist/src/proxy/client.test.d.ts.map +1 -0
- package/dist/src/proxy/client.test.js +167 -0
- package/dist/src/proxy/client.test.js.map +1 -0
- package/dist/src/proxy/hooks/apiKeyHook.d.ts +22 -0
- package/dist/src/proxy/hooks/apiKeyHook.d.ts.map +1 -0
- package/dist/src/proxy/hooks/apiKeyHook.js +72 -0
- package/dist/src/proxy/hooks/apiKeyHook.js.map +1 -0
- package/dist/src/proxy/hooks/apiKeyHook.test.d.ts +2 -0
- package/dist/src/proxy/hooks/apiKeyHook.test.d.ts.map +1 -0
- package/dist/src/proxy/hooks/apiKeyHook.test.js +240 -0
- package/dist/src/proxy/hooks/apiKeyHook.test.js.map +1 -0
- package/dist/src/proxy/index.d.ts +4 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +4 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/proxy/server.d.ts +18 -0
- package/dist/src/proxy/server.d.ts.map +1 -0
- package/dist/src/proxy/server.js +35 -0
- package/dist/src/proxy/server.js.map +1 -0
- package/dist/src/proxy/server.test.d.ts +2 -0
- package/dist/src/proxy/server.test.d.ts.map +1 -0
- package/dist/src/proxy/server.test.js +26 -0
- package/dist/src/proxy/server.test.js.map +1 -0
- package/dist/src/server.d.ts +56 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +320 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/server.test.d.ts +2 -0
- package/dist/src/server.test.d.ts.map +1 -0
- package/dist/src/server.test.js +666 -0
- package/dist/src/server.test.js.map +1 -0
- package/dist/src/util.d.ts +24 -0
- package/dist/src/util.d.ts.map +1 -0
- package/dist/src/util.js +47 -0
- package/dist/src/util.js.map +1 -0
- package/dist/src/util.test.d.ts +2 -0
- package/dist/src/util.test.d.ts.map +1 -0
- package/dist/src/util.test.js +71 -0
- package/dist/src/util.test.js.map +1 -0
- package/dist/src/x402Transport.d.ts +45 -0
- package/dist/src/x402Transport.d.ts.map +1 -0
- package/dist/src/x402Transport.js +288 -0
- package/dist/src/x402Transport.js.map +1 -0
- package/example/client.ts +125 -0
- package/example/config.ts +25 -0
- package/example/proxy/README.md +95 -0
- package/example/proxy/client-proxy.ts +102 -0
- package/example/proxy/client.ts +112 -0
- package/example/proxy/server-proxy.ts +80 -0
- package/example/server.ts +104 -0
- package/example/service.ts +19 -0
- package/example-client-proxy.sh +3 -0
- package/mcp-servers.json +9 -0
- package/package.json +53 -0
- package/scripts/analyzePayment.ts +25 -0
- package/scripts/client-proxy.ts +142 -0
- package/scripts/generateWallet.ts +17 -0
- package/src/client.test.ts +237 -0
- package/src/client.ts +61 -0
- package/src/index.test.ts +34 -0
- package/src/index.ts +7 -0
- package/src/proxy/client.test.ts +199 -0
- package/src/proxy/client.ts +61 -0
- package/src/proxy/hooks/apiKeyHook.test.ts +276 -0
- package/src/proxy/hooks/apiKeyHook.ts +77 -0
- package/src/proxy/index.ts +3 -0
- package/src/proxy/server.test.ts +33 -0
- package/src/proxy/server.ts +43 -0
- package/src/server.test.ts +822 -0
- package/src/server.ts +451 -0
- package/src/util.test.ts +83 -0
- package/src/util.ts +48 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +26 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebFetch(domain:raw.githubusercontent.com)",
|
|
5
|
+
"WebFetch(domain:api.github.com)",
|
|
6
|
+
"WebFetch(domain:docs.cdp.coinbase.com)",
|
|
7
|
+
"Bash(pnpm build:*)",
|
|
8
|
+
"WebFetch(domain:www.npmjs.com)",
|
|
9
|
+
"WebFetch(domain:github.com)",
|
|
10
|
+
"WebFetch(domain:x402.org)",
|
|
11
|
+
"Bash(find:*)",
|
|
12
|
+
"Bash(grep:*)",
|
|
13
|
+
"Bash(ls:*)",
|
|
14
|
+
"Bash(mkdir:*)",
|
|
15
|
+
"Bash(mv:*)",
|
|
16
|
+
"Bash(pnpm add:*)",
|
|
17
|
+
"Bash(pnpm test:*)",
|
|
18
|
+
"WebFetch(domain:x402.gitbook.io)",
|
|
19
|
+
"Bash(gh run list:*)",
|
|
20
|
+
"Bash(gh run view:*)",
|
|
21
|
+
"Bash(pnpm lint:fix:*)",
|
|
22
|
+
"Bash(pnpm lint:*)"
|
|
23
|
+
],
|
|
24
|
+
"deny": []
|
|
25
|
+
}
|
|
26
|
+
}
|
package/.env.example
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# For mainnet, use:
|
|
2
|
+
# PAYMENT_NETWORK=base
|
|
3
|
+
# FACILITATOR_URL=<mainnet facilitator url> See here: https://docs.cdp.coinbase.com/x402/network-support
|
|
4
|
+
PAYMENT_NETWORK=base-sepolia
|
|
5
|
+
FACILITATOR_URL=https://x402.org/facilitator
|
|
6
|
+
SENDER_PRIVATE_KEY=0xb81462e5590e4b708a1febadb33bedfed75d94883a7a42d4836dd8e2d46f7f65
|
|
7
|
+
SENDER_WALLET_ADDRESS=0xYourWalletAddressHere
|
|
8
|
+
MCP_SERVER_URL=http://localhost:3022/mcp
|
|
9
|
+
|
|
10
|
+
RECEIVER_WALLET_ADDRESS=0xYourWalletAddressHere
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Lint
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout code
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Install pnpm
|
|
19
|
+
uses: pnpm/action-setup@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 20.x
|
|
25
|
+
cache: 'pnpm'
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: pnpm install --frozen-lockfile
|
|
29
|
+
|
|
30
|
+
- name: Run Biome lint
|
|
31
|
+
run: pnpm lint
|
|
32
|
+
|
|
33
|
+
test:
|
|
34
|
+
name: Test
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
strategy:
|
|
37
|
+
matrix:
|
|
38
|
+
node-version: [20.x, 22.x, 24.x]
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- name: Checkout code
|
|
42
|
+
uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: Install pnpm
|
|
45
|
+
uses: pnpm/action-setup@v4
|
|
46
|
+
|
|
47
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
48
|
+
uses: actions/setup-node@v4
|
|
49
|
+
with:
|
|
50
|
+
node-version: ${{ matrix.node-version }}
|
|
51
|
+
cache: 'pnpm'
|
|
52
|
+
|
|
53
|
+
- name: Install dependencies
|
|
54
|
+
run: pnpm install --frozen-lockfile
|
|
55
|
+
|
|
56
|
+
- name: Run build
|
|
57
|
+
run: pnpm build
|
|
58
|
+
|
|
59
|
+
- name: Run tests with coverage
|
|
60
|
+
run: pnpm test:coverage
|
|
61
|
+
|
|
62
|
+
- name: Upload coverage to Codecov
|
|
63
|
+
if: matrix.node-version == '20.x'
|
|
64
|
+
uses: codecov/codecov-action@v5
|
|
65
|
+
with:
|
|
66
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
67
|
+
directory: ./coverage
|
|
68
|
+
fail_ci_if_error: false
|
|
69
|
+
verbose: true
|
|
70
|
+
|
|
71
|
+
type-check:
|
|
72
|
+
name: Type Check
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
|
|
75
|
+
steps:
|
|
76
|
+
- name: Checkout code
|
|
77
|
+
uses: actions/checkout@v4
|
|
78
|
+
|
|
79
|
+
- name: Install pnpm
|
|
80
|
+
uses: pnpm/action-setup@v4
|
|
81
|
+
|
|
82
|
+
- name: Setup Node.js
|
|
83
|
+
uses: actions/setup-node@v4
|
|
84
|
+
with:
|
|
85
|
+
node-version: 20.x
|
|
86
|
+
cache: 'pnpm'
|
|
87
|
+
|
|
88
|
+
- name: Install dependencies
|
|
89
|
+
run: pnpm install --frozen-lockfile
|
|
90
|
+
|
|
91
|
+
- name: Run TypeScript compiler
|
|
92
|
+
run: pnpm tsc --noEmit
|
|
93
|
+
|
|
94
|
+
examples:
|
|
95
|
+
name: Build Examples
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
|
|
98
|
+
steps:
|
|
99
|
+
- name: Checkout code
|
|
100
|
+
uses: actions/checkout@v4
|
|
101
|
+
|
|
102
|
+
- name: Install pnpm
|
|
103
|
+
uses: pnpm/action-setup@v4
|
|
104
|
+
|
|
105
|
+
- name: Setup Node.js
|
|
106
|
+
uses: actions/setup-node@v4
|
|
107
|
+
with:
|
|
108
|
+
node-version: 20.x
|
|
109
|
+
cache: 'pnpm'
|
|
110
|
+
|
|
111
|
+
- name: Install dependencies
|
|
112
|
+
run: pnpm install --frozen-lockfile
|
|
113
|
+
|
|
114
|
+
- name: Build library
|
|
115
|
+
run: pnpm build
|
|
116
|
+
|
|
117
|
+
- name: Test example scripts
|
|
118
|
+
run: |
|
|
119
|
+
pnpm tsx --version
|
|
120
|
+
node --version
|
|
121
|
+
|
|
122
|
+
security-audit:
|
|
123
|
+
name: Security Audit
|
|
124
|
+
runs-on: ubuntu-latest
|
|
125
|
+
|
|
126
|
+
steps:
|
|
127
|
+
- name: Checkout code
|
|
128
|
+
uses: actions/checkout@v4
|
|
129
|
+
|
|
130
|
+
- name: Install pnpm
|
|
131
|
+
uses: pnpm/action-setup@v4
|
|
132
|
+
|
|
133
|
+
- name: Setup Node.js
|
|
134
|
+
uses: actions/setup-node@v4
|
|
135
|
+
with:
|
|
136
|
+
node-version: 20.x
|
|
137
|
+
cache: 'pnpm'
|
|
138
|
+
|
|
139
|
+
- name: Install dependencies
|
|
140
|
+
run: pnpm install --frozen-lockfile
|
|
141
|
+
|
|
142
|
+
- name: Run security audit
|
|
143
|
+
run: pnpm audit --audit-level moderate
|
|
144
|
+
continue-on-error: true
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
name: Release
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install pnpm
|
|
22
|
+
uses: pnpm/action-setup@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Node.js
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20.x
|
|
28
|
+
cache: 'pnpm'
|
|
29
|
+
registry-url: 'https://registry.npmjs.org'
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: pnpm install --frozen-lockfile
|
|
33
|
+
|
|
34
|
+
- name: Run build
|
|
35
|
+
run: pnpm build
|
|
36
|
+
|
|
37
|
+
- name: Run tests
|
|
38
|
+
run: pnpm test run
|
|
39
|
+
|
|
40
|
+
- name: Publish to npm
|
|
41
|
+
run: npm publish --access public --provenance
|
|
42
|
+
env:
|
|
43
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
44
|
+
|
|
45
|
+
- name: Create GitHub Release
|
|
46
|
+
uses: actions/create-release@v1
|
|
47
|
+
env:
|
|
48
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
+
with:
|
|
50
|
+
tag_name: ${{ github.ref }}
|
|
51
|
+
release_name: Release ${{ github.ref }}
|
|
52
|
+
body: |
|
|
53
|
+
Changes in this release:
|
|
54
|
+
- See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details
|
|
55
|
+
draft: false
|
|
56
|
+
prerelease: false
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/x402-mcp-example.iml" filepath="$PROJECT_DIR$/.idea/x402-mcp-example.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
<excludeFolder url="file://$MODULE_DIR$/coverage" />
|
|
9
|
+
</content>
|
|
10
|
+
<orderEntry type="inheritedJdk" />
|
|
11
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
12
|
+
</component>
|
|
13
|
+
</module>
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Civic MCP Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
- The project requires heavy understanding of the Model Context Protocol (MCP), which is defined here: https://modelcontextprotocol.io/specification/2025-06-18 , and x402, which is defined here: https://x402.gitbook.io/x402
|
|
5
|
+
|
|
6
|
+
## Style Guidelines
|
|
7
|
+
- All code should be typescript.
|
|
8
|
+
- Use pnpm as the package manager.
|
|
9
|
+
- Do not use dynamic imports unless there's a very good reason to do so.
|
|
10
|
+
- Except in tests, no stub or placeholder code unless explicitly requested or stated in the spec.
|
|
11
|
+
- Keep functions small where appropriate.
|
|
12
|
+
|
|
13
|
+
### Testing Strategy
|
|
14
|
+
|
|
15
|
+
- **Unit Tests**: Test individual functions and services in isolation
|
|
16
|
+
- **Integration Tests**: Test the interaction between multiple services
|
|
17
|
+
- Place tests alongside source files when testing specific functions
|
|
18
|
+
- Use mocks/stubs for external services
|
|
19
|
+
- Use vitest for unit testing.
|
|
20
|
+
- Use playwright for browser-based e2e testing where appropriate
|
|
21
|
+
- Avoid use of 'any'
|
|
22
|
+
- Use stubGlobal and stubEnv if needed, do not change the global or env vars directly
|
|
23
|
+
- Use vi.mocked(...) to provide typesafety when creating expectations
|
|
24
|
+
- Use the Martin Fowler definitions of stubs, mocks, fakes, dummies etc rather than always calling things mocks.
|
|
25
|
+
- Target 90% unit test coverage
|
|
26
|
+
|
|
27
|
+
# Overall guidelines
|
|
28
|
+
- Whenever making any large changes, first propose a plan, and wait for confirmation before implementing it.
|
|
29
|
+
- No "in a real implementation", you are building the real implementation.
|
|
30
|
+
- No need to maintain legacy solutions, unless explicitly stated, clean up old solutions as you go, to keep the code clean and well-structured.
|
|
31
|
+
- So unless told otherwise, no "backwards-compatibility"
|
package/DEVELOPER.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Developer Guide
|
|
2
|
+
|
|
3
|
+
## Development Setup
|
|
4
|
+
|
|
5
|
+
### Prerequisites
|
|
6
|
+
- Node.js 20.x or higher
|
|
7
|
+
- pnpm 9.15.4 (automatically installed via corepack if needed)
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
```bash
|
|
11
|
+
# Clone the repository
|
|
12
|
+
git clone https://github.com/civicteam/x402-mcp.git
|
|
13
|
+
cd x402-mcp
|
|
14
|
+
|
|
15
|
+
# Install dependencies
|
|
16
|
+
pnpm install
|
|
17
|
+
|
|
18
|
+
# Build the project
|
|
19
|
+
pnpm build
|
|
20
|
+
|
|
21
|
+
# Run tests
|
|
22
|
+
pnpm test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Development Workflow
|
|
26
|
+
|
|
27
|
+
### Available Scripts
|
|
28
|
+
- `pnpm dev` - Start the development server with hot reload
|
|
29
|
+
- `pnpm build` - Build the TypeScript project
|
|
30
|
+
- `pnpm test` - Run tests in watch mode
|
|
31
|
+
- `pnpm test:coverage` - Run tests with coverage report
|
|
32
|
+
- `pnpm start` - Start the example server
|
|
33
|
+
- `pnpm example:run` - Run the example client
|
|
34
|
+
- `pnpm generate-wallet` - Generate a new wallet for testing
|
|
35
|
+
|
|
36
|
+
### Testing
|
|
37
|
+
The project uses Vitest for unit testing. Tests should be placed alongside source files or in a `__tests__` directory.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Run tests in watch mode
|
|
41
|
+
pnpm test
|
|
42
|
+
|
|
43
|
+
# Run tests once with coverage
|
|
44
|
+
pnpm test:coverage
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Release Process
|
|
48
|
+
|
|
49
|
+
### Prerequisites for Releasing
|
|
50
|
+
1. Ensure you have npm publish access to the `@civic` org
|
|
51
|
+
2. Set up GitHub repository secrets:
|
|
52
|
+
- `NPM_PUBLISH_TOKEN` - npm automation token for publishing
|
|
53
|
+
- `CODECOV_TOKEN` (optional) - for coverage reporting
|
|
54
|
+
|
|
55
|
+
### Release Steps
|
|
56
|
+
|
|
57
|
+
#### 1. Prepare the Release
|
|
58
|
+
```bash
|
|
59
|
+
# Ensure you're on the main branch with latest changes
|
|
60
|
+
git checkout main
|
|
61
|
+
git pull origin main
|
|
62
|
+
|
|
63
|
+
# Run tests and build to verify everything works
|
|
64
|
+
pnpm test:coverage
|
|
65
|
+
pnpm build
|
|
66
|
+
|
|
67
|
+
# Update the version in package.json
|
|
68
|
+
npm version patch # or minor/major
|
|
69
|
+
# This creates a commit and tag automatically
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### 2. Push the Release
|
|
73
|
+
```bash
|
|
74
|
+
# Push the commit and tag to trigger the release workflow
|
|
75
|
+
git push origin main
|
|
76
|
+
git push origin --tags
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### 3. Automated Release Process
|
|
80
|
+
Once you push the tag, GitHub Actions will automatically:
|
|
81
|
+
1. Run the full test suite across Node.js 20.x, 22.x, and 24.x
|
|
82
|
+
2. Perform type checking
|
|
83
|
+
3. Run security audits
|
|
84
|
+
4. Build the project
|
|
85
|
+
5. Publish to npm with provenance attestation
|
|
86
|
+
6. Create a GitHub release
|
|
87
|
+
|
|
88
|
+
#### 4. Verify the Release
|
|
89
|
+
- Check the [GitHub Actions](https://github.com/civicteam/x402-mcp/actions) page for build status
|
|
90
|
+
- Verify the package on [npm](https://www.npmjs.com/package/@civic/x402-mcp)
|
|
91
|
+
- Check the [GitHub Releases](https://github.com/civicteam/x402-mcp/releases) page
|
|
92
|
+
|
|
93
|
+
### Version Guidelines
|
|
94
|
+
- **Patch** (x.x.1): Bug fixes, documentation updates
|
|
95
|
+
- **Minor** (x.1.x): New features, backward-compatible changes
|
|
96
|
+
- **Major** (1.x.x): Breaking changes, major refactors
|
|
97
|
+
|
|
98
|
+
### Pre-release Versions
|
|
99
|
+
For testing releases before making them public:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Create a pre-release version
|
|
103
|
+
npm version prerelease --preid=beta
|
|
104
|
+
# Results in: 1.0.1-beta.0
|
|
105
|
+
|
|
106
|
+
# Publish with beta tag
|
|
107
|
+
npm publish --tag beta
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Manual Publishing (Emergency Only)
|
|
111
|
+
If the automated release fails, you can publish manually:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Ensure you're authenticated to npm
|
|
115
|
+
npm login
|
|
116
|
+
|
|
117
|
+
# Build the project
|
|
118
|
+
pnpm build
|
|
119
|
+
|
|
120
|
+
# Publish to npm
|
|
121
|
+
npm publish --access public
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## CI/CD Pipeline
|
|
125
|
+
|
|
126
|
+
### Continuous Integration
|
|
127
|
+
The CI workflow runs on every push to `main` and on pull requests:
|
|
128
|
+
- **Test Matrix**: Tests against Node.js 20.x, 22.x, and 24.x
|
|
129
|
+
- **Type Checking**: Validates TypeScript types
|
|
130
|
+
- **Security Audit**: Checks for known vulnerabilities
|
|
131
|
+
- **Coverage**: Reports test coverage to Codecov
|
|
132
|
+
|
|
133
|
+
### Release Automation
|
|
134
|
+
The release workflow triggers on version tags (`v*`):
|
|
135
|
+
- Builds and tests the project
|
|
136
|
+
- Publishes to npm with provenance
|
|
137
|
+
- Creates a GitHub release
|
|
138
|
+
|
|
139
|
+
## Troubleshooting
|
|
140
|
+
|
|
141
|
+
### Common Issues
|
|
142
|
+
|
|
143
|
+
#### Build Failures
|
|
144
|
+
```bash
|
|
145
|
+
# Clean build artifacts
|
|
146
|
+
rm -rf dist/
|
|
147
|
+
pnpm build
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Test Failures
|
|
151
|
+
```bash
|
|
152
|
+
# Run tests with verbose output
|
|
153
|
+
pnpm test -- --reporter=verbose
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Publishing Issues
|
|
157
|
+
- Ensure you're logged into npm: `npm whoami`
|
|
158
|
+
- Check npm access: `npm access ls-packages @civic`
|
|
159
|
+
- Verify the package name isn't taken: `npm view @civic/x402-mcp`
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
### Pull Request Process
|
|
164
|
+
1. Fork the repository
|
|
165
|
+
2. Create a feature branch: `git checkout -b feature/my-feature`
|
|
166
|
+
3. Make your changes and add tests
|
|
167
|
+
4. Ensure all tests pass: `pnpm test:coverage`
|
|
168
|
+
5. Commit with descriptive messages
|
|
169
|
+
6. Push to your fork and create a PR
|
|
170
|
+
|
|
171
|
+
### Code Style
|
|
172
|
+
- TypeScript with strict typing
|
|
173
|
+
- No use of `any` type
|
|
174
|
+
- Functional programming preferred
|
|
175
|
+
- Small, focused functions
|
|
176
|
+
- JSDoc comments for public APIs
|
|
177
|
+
|
|
178
|
+
### Commit Guidelines
|
|
179
|
+
- Clear, descriptive commit messages
|
|
180
|
+
- Present tense ("Add feature" not "Added feature")
|
|
181
|
+
- Reference issues when applicable
|