@manifest-network/manifest-mcp-browser 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/.claude/settings.local.json +17 -0
- package/.github/workflows/ci.yml +37 -0
- package/.github/workflows/publish.yml +51 -0
- package/CLAUDE.md +104 -0
- package/LICENSE +21 -0
- package/README.md +298 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js.map +1 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +131 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/config.test.d.ts +2 -0
- package/dist/config.test.d.ts.map +1 -0
- package/dist/config.test.js +123 -0
- package/dist/config.test.js.map +1 -0
- package/dist/cosmos.d.ts +11 -0
- package/dist/cosmos.d.ts.map +1 -0
- package/dist/cosmos.js +112 -0
- package/dist/cosmos.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -0
- package/dist/modules.d.ts +30 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +221 -0
- package/dist/modules.js.map +1 -0
- package/dist/modules.test.d.ts +2 -0
- package/dist/modules.test.d.ts.map +1 -0
- package/dist/modules.test.js +100 -0
- package/dist/modules.test.js.map +1 -0
- package/dist/queries/auth.d.ts +6 -0
- package/dist/queries/auth.d.ts.map +1 -0
- package/dist/queries/auth.js +93 -0
- package/dist/queries/auth.js.map +1 -0
- package/dist/queries/bank.d.ts +6 -0
- package/dist/queries/bank.d.ts.map +1 -0
- package/dist/queries/bank.js +83 -0
- package/dist/queries/bank.js.map +1 -0
- package/dist/queries/billing.d.ts +6 -0
- package/dist/queries/billing.d.ts.map +1 -0
- package/dist/queries/billing.js +115 -0
- package/dist/queries/billing.js.map +1 -0
- package/dist/queries/distribution.d.ts +6 -0
- package/dist/queries/distribution.d.ts.map +1 -0
- package/dist/queries/distribution.js +102 -0
- package/dist/queries/distribution.js.map +1 -0
- package/dist/queries/gov.d.ts +6 -0
- package/dist/queries/gov.d.ts.map +1 -0
- package/dist/queries/gov.js +92 -0
- package/dist/queries/gov.js.map +1 -0
- package/dist/queries/index.d.ts +8 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +8 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/manifest.d.ts +10 -0
- package/dist/queries/manifest.d.ts.map +1 -0
- package/dist/queries/manifest.js +14 -0
- package/dist/queries/manifest.js.map +1 -0
- package/dist/queries/staking.d.ts +6 -0
- package/dist/queries/staking.d.ts.map +1 -0
- package/dist/queries/staking.js +141 -0
- package/dist/queries/staking.js.map +1 -0
- package/dist/queries/utils.d.ts +22 -0
- package/dist/queries/utils.d.ts.map +1 -0
- package/dist/queries/utils.js +32 -0
- package/dist/queries/utils.js.map +1 -0
- package/dist/queries/utils.test.d.ts +2 -0
- package/dist/queries/utils.test.d.ts.map +1 -0
- package/dist/queries/utils.test.js +57 -0
- package/dist/queries/utils.test.js.map +1 -0
- package/dist/transactions/bank.d.ts +7 -0
- package/dist/transactions/bank.d.ts.map +1 -0
- package/dist/transactions/bank.js +76 -0
- package/dist/transactions/bank.js.map +1 -0
- package/dist/transactions/billing.d.ts +7 -0
- package/dist/transactions/billing.d.ts.map +1 -0
- package/dist/transactions/billing.js +108 -0
- package/dist/transactions/billing.js.map +1 -0
- package/dist/transactions/distribution.d.ts +7 -0
- package/dist/transactions/distribution.d.ts.map +1 -0
- package/dist/transactions/distribution.js +63 -0
- package/dist/transactions/distribution.js.map +1 -0
- package/dist/transactions/gov.d.ts +7 -0
- package/dist/transactions/gov.d.ts.map +1 -0
- package/dist/transactions/gov.js +132 -0
- package/dist/transactions/gov.js.map +1 -0
- package/dist/transactions/index.d.ts +8 -0
- package/dist/transactions/index.d.ts.map +1 -0
- package/dist/transactions/index.js +8 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/transactions/manifest.d.ts +7 -0
- package/dist/transactions/manifest.d.ts.map +1 -0
- package/dist/transactions/manifest.js +58 -0
- package/dist/transactions/manifest.js.map +1 -0
- package/dist/transactions/staking.d.ts +7 -0
- package/dist/transactions/staking.d.ts.map +1 -0
- package/dist/transactions/staking.js +72 -0
- package/dist/transactions/staking.js.map +1 -0
- package/dist/transactions/utils.d.ts +40 -0
- package/dist/transactions/utils.d.ts.map +1 -0
- package/dist/transactions/utils.js +114 -0
- package/dist/transactions/utils.js.map +1 -0
- package/dist/transactions/utils.test.d.ts +2 -0
- package/dist/transactions/utils.test.d.ts.map +1 -0
- package/dist/transactions/utils.test.js +121 -0
- package/dist/transactions/utils.test.js.map +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +55 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet/index.d.ts +3 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +2 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/keplr.d.ts.map +1 -0
- package/dist/wallet/keplr.js.map +1 -0
- package/dist/wallet/mnemonic.d.ts +40 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -0
- package/dist/wallet/mnemonic.js +87 -0
- package/dist/wallet/mnemonic.js.map +1 -0
- package/package.json +40 -0
- package/src/client.ts +178 -0
- package/src/config.test.ts +143 -0
- package/src/config.ts +122 -0
- package/src/cosmos.ts +196 -0
- package/src/index.ts +484 -0
- package/src/modules.test.ts +127 -0
- package/src/modules.ts +278 -0
- package/src/queries/auth.ts +136 -0
- package/src/queries/bank.ts +117 -0
- package/src/queries/billing.ts +164 -0
- package/src/queries/distribution.ts +138 -0
- package/src/queries/gov.ts +128 -0
- package/src/queries/index.ts +7 -0
- package/src/queries/staking.ts +190 -0
- package/src/queries/utils.test.ts +61 -0
- package/src/queries/utils.ts +38 -0
- package/src/transactions/bank.ts +110 -0
- package/src/transactions/billing.ts +160 -0
- package/src/transactions/distribution.ts +98 -0
- package/src/transactions/gov.ts +185 -0
- package/src/transactions/index.ts +7 -0
- package/src/transactions/manifest.ts +89 -0
- package/src/transactions/staking.ts +107 -0
- package/src/transactions/utils.test.ts +129 -0
- package/src/transactions/utils.ts +156 -0
- package/src/types.ts +152 -0
- package/src/wallet/index.ts +2 -0
- package/src/wallet/mnemonic.ts +122 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(npm run lint)",
|
|
5
|
+
"Bash(npm install:*)",
|
|
6
|
+
"Bash(npm test:*)",
|
|
7
|
+
"Bash(git init:*)",
|
|
8
|
+
"Bash(npm run build:*)",
|
|
9
|
+
"Bash(find:*)",
|
|
10
|
+
"Bash(node -e:*)",
|
|
11
|
+
"Bash(ls:*)",
|
|
12
|
+
"Bash(git config:*)",
|
|
13
|
+
"WebFetch(domain:docs.npmjs.com)",
|
|
14
|
+
"WebSearch"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [18, 20, 22]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: 'npm'
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Run linter
|
|
31
|
+
run: npm run lint
|
|
32
|
+
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: npm test
|
|
35
|
+
|
|
36
|
+
- name: Build
|
|
37
|
+
run: npm run build
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
# Required for npm trusted publishing (OIDC)
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 20
|
|
25
|
+
registry-url: 'https://registry.npmjs.org'
|
|
26
|
+
cache: 'npm'
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: npm ci
|
|
30
|
+
|
|
31
|
+
- name: Run linter
|
|
32
|
+
run: npm run lint
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: npm test
|
|
36
|
+
|
|
37
|
+
- name: Build
|
|
38
|
+
run: npm run build
|
|
39
|
+
|
|
40
|
+
- name: Verify package version matches tag
|
|
41
|
+
run: |
|
|
42
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
43
|
+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
|
44
|
+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
|
|
45
|
+
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
echo "Version verified: $PACKAGE_VERSION"
|
|
49
|
+
|
|
50
|
+
- name: Publish to npm
|
|
51
|
+
run: npm publish --access public
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Browser-compatible MCP (Model Context Protocol) server for Cosmos SDK blockchain interactions with Manifest Network using CosmJS. This is a browser-friendly alternative to `manifest-mcp` that uses CosmJS/HTTP instead of CLI.
|
|
8
|
+
|
|
9
|
+
## Build Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm run build # TypeScript compilation to dist/
|
|
13
|
+
npm run dev # Watch mode for TypeScript
|
|
14
|
+
npm run lint # Type-check without emitting (tsc --noEmit)
|
|
15
|
+
npm test # Run tests with vitest
|
|
16
|
+
npm run test:watch # Run tests in watch mode
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Architecture
|
|
20
|
+
|
|
21
|
+
### Entry Point
|
|
22
|
+
|
|
23
|
+
- `src/index.ts` - Main entry point, exports `ManifestMCPServer` class, `createMnemonicServer()`, and all public APIs
|
|
24
|
+
|
|
25
|
+
### Core Components
|
|
26
|
+
|
|
27
|
+
**ManifestMCPServer** (`src/index.ts`)
|
|
28
|
+
- Wraps MCP SDK `Server` to handle tool requests
|
|
29
|
+
- Exposes 5 MCP tools: `get_account_info`, `cosmos_query`, `cosmos_tx`, `list_modules`, `list_module_subcommands`
|
|
30
|
+
|
|
31
|
+
**CosmosClientManager** (`src/client.ts`)
|
|
32
|
+
- Singleton pattern per chainId:rpcUrl combination
|
|
33
|
+
- Provides lazy-initialized query client (manifestjs RPC) and signing client (CosmJS Stargate)
|
|
34
|
+
- Registers all Manifest protobuf types from `@manifest-network/manifestjs`
|
|
35
|
+
|
|
36
|
+
**Wallet Providers** (`src/wallet/`)
|
|
37
|
+
- `WalletProvider` interface defines `getAddress()` and `getSigner()` methods (wallet-agnostic)
|
|
38
|
+
- Any wallet providing `OfflineSigner` works (cosmos-kit, Web3Auth, Keplr, Leap, etc.)
|
|
39
|
+
- `MnemonicWalletProvider` - Built-in provider using `DirectSecp256k1HdWallet` for testing
|
|
40
|
+
|
|
41
|
+
### Query/Transaction Routing
|
|
42
|
+
|
|
43
|
+
**cosmos.ts** - Main router that validates module/subcommand names and dispatches to module handlers
|
|
44
|
+
|
|
45
|
+
**queries/** - Module-specific query handlers
|
|
46
|
+
- Each file exports `route{Module}Query()` function
|
|
47
|
+
- Uses manifestjs RPC query client (`liftedinit.ClientFactory.createRPCQueryClient`)
|
|
48
|
+
- Shared utilities in `utils.ts`: `parseBigInt()`, `parseInt()`, `defaultPagination`
|
|
49
|
+
- All paginated queries use `DEFAULT_PAGE_LIMIT` (100) to prevent resource exhaustion
|
|
50
|
+
|
|
51
|
+
**transactions/** - Module-specific transaction handlers
|
|
52
|
+
- Each file exports `route{Module}Transaction()` function
|
|
53
|
+
- Uses CosmJS `SigningStargateClient` with Manifest registries
|
|
54
|
+
- Uses manifestjs enums (e.g., `VoteOption` from `cosmos.gov.v1`)
|
|
55
|
+
- Shared utilities in `utils.ts`:
|
|
56
|
+
- `parseAmount()` - Parse amount strings with helpful error hints
|
|
57
|
+
- `parseBigIntWithCode()` - Base implementation used by both queries and transactions
|
|
58
|
+
- `validateAddress()` - Bech32 validation using `@cosmjs/encoding`
|
|
59
|
+
- `validateMemo()` - Enforce 256 char limit (Cosmos SDK default)
|
|
60
|
+
- `validateArgsLength()` - Enforce 100 args max to prevent DoS
|
|
61
|
+
- `buildTxResult()` - Build transaction result objects
|
|
62
|
+
|
|
63
|
+
**modules.ts** - Static registry of all supported modules and subcommands (no dynamic CLI discovery)
|
|
64
|
+
|
|
65
|
+
### Supported Modules
|
|
66
|
+
|
|
67
|
+
Query: bank, staking, distribution, gov, auth, billing
|
|
68
|
+
Transaction: bank, staking, distribution, gov, billing, manifest
|
|
69
|
+
|
|
70
|
+
### Key Dependencies
|
|
71
|
+
|
|
72
|
+
- `@manifest-network/manifestjs` - Protobuf types, registries, RPC client factory, and enums (e.g., `VoteOption`)
|
|
73
|
+
- `@modelcontextprotocol/sdk` - MCP server implementation
|
|
74
|
+
- `@cosmjs/stargate` - Signing client, gas price parsing
|
|
75
|
+
- `@cosmjs/encoding` - Bech32 address validation (`fromBech32`)
|
|
76
|
+
- `@cosmjs/proto-signing` - Wallet and signer interfaces
|
|
77
|
+
|
|
78
|
+
### Security Features
|
|
79
|
+
|
|
80
|
+
**Input Validation:**
|
|
81
|
+
- Bech32 address validation using `@cosmjs/encoding`
|
|
82
|
+
- Amount format validation with helpful error hints
|
|
83
|
+
- Memo length limit (256 chars, Cosmos SDK default)
|
|
84
|
+
- Args array length limit (100 max)
|
|
85
|
+
- BigInt empty string rejection (prevents silent 0n)
|
|
86
|
+
- Hex string validation for address-bytes queries
|
|
87
|
+
|
|
88
|
+
**Resource Limits:**
|
|
89
|
+
- Default pagination limit of 100 items for all list queries
|
|
90
|
+
- Transaction broadcast timeout (60 seconds)
|
|
91
|
+
- Broadcast poll interval (3 seconds)
|
|
92
|
+
|
|
93
|
+
**Sensitive Data:**
|
|
94
|
+
- Error responses sanitize sensitive fields (mnemonic, privateKey, secret, etc.)
|
|
95
|
+
- Mnemonic cleared on wallet disconnect
|
|
96
|
+
- No logging of sensitive data
|
|
97
|
+
|
|
98
|
+
### Error Handling
|
|
99
|
+
|
|
100
|
+
All errors use `ManifestMCPError` class with typed `ManifestMCPErrorCode` enum (see `src/types.ts`).
|
|
101
|
+
|
|
102
|
+
### Type Exports
|
|
103
|
+
|
|
104
|
+
`ManifestQueryClient` type in `client.ts` is derived from manifestjs `liftedinit.ClientFactory.createRPCQueryClient` return type.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Felix C. Morency
|
|
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,298 @@
|
|
|
1
|
+
# @manifest-network/manifest-mcp-browser
|
|
2
|
+
|
|
3
|
+
Browser-compatible MCP server for Cosmos SDK blockchain interactions with Manifest Network using CosmJS.
|
|
4
|
+
|
|
5
|
+
This package provides the same MCP tool interface as `manifest-mcp`, but uses CosmJS instead of CLI for browser compatibility.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @manifest-network/manifest-mcp-browser
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run build # TypeScript compilation to dist/
|
|
17
|
+
npm run dev # Watch mode for TypeScript
|
|
18
|
+
npm run lint # Type-check without emitting
|
|
19
|
+
npm test # Run tests
|
|
20
|
+
npm run test:watch # Run tests in watch mode
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### With Any Wallet (cosmos-kit, Web3Auth, etc.)
|
|
26
|
+
|
|
27
|
+
The MCP server works with any wallet that provides an `OfflineSigner`:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { ManifestMCPServer, WalletProvider } from '@manifest-network/manifest-mcp-browser';
|
|
31
|
+
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
32
|
+
|
|
33
|
+
// Create a wallet provider from your existing signer
|
|
34
|
+
const walletProvider: WalletProvider = {
|
|
35
|
+
getAddress: async () => address,
|
|
36
|
+
getSigner: async () => yourOfflineSigner,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const server = new ManifestMCPServer({
|
|
40
|
+
config: {
|
|
41
|
+
chainId: 'manifest-ledger-testnet',
|
|
42
|
+
rpcUrl: 'https://nodes.chandrastation.com/rpc/manifest/',
|
|
43
|
+
gasPrice: '1.0umfx',
|
|
44
|
+
},
|
|
45
|
+
walletProvider,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### With cosmos-kit
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { useChain } from '@cosmos-kit/react';
|
|
53
|
+
import { ManifestMCPServer, WalletProvider } from '@manifest-network/manifest-mcp-browser';
|
|
54
|
+
|
|
55
|
+
function MyComponent() {
|
|
56
|
+
const { address, getOfflineSigner } = useChain('manifest');
|
|
57
|
+
|
|
58
|
+
const walletProvider: WalletProvider = {
|
|
59
|
+
getAddress: async () => address!,
|
|
60
|
+
getSigner: async () => getOfflineSigner(),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const server = new ManifestMCPServer({
|
|
64
|
+
config: {
|
|
65
|
+
chainId: 'manifest-ledger-testnet',
|
|
66
|
+
rpcUrl: 'https://nodes.chandrastation.com/rpc/manifest/',
|
|
67
|
+
gasPrice: '1.0umfx',
|
|
68
|
+
},
|
|
69
|
+
walletProvider,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Testing with Mnemonic
|
|
75
|
+
|
|
76
|
+
For testing or non-interactive environments:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { createMnemonicServer } from '@manifest-network/manifest-mcp-browser';
|
|
80
|
+
|
|
81
|
+
const server = await createMnemonicServer({
|
|
82
|
+
chainId: 'manifest-ledger-testnet',
|
|
83
|
+
rpcUrl: 'https://nodes.chandrastation.com/rpc/manifest/',
|
|
84
|
+
gasPrice: '1.0umfx',
|
|
85
|
+
mnemonic: 'your twelve word mnemonic phrase here...',
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## MCP Tools
|
|
90
|
+
|
|
91
|
+
The server exposes the same five tools as `manifest-mcp`:
|
|
92
|
+
|
|
93
|
+
1. **get_account_info** - Get the wallet's account address
|
|
94
|
+
2. **cosmos_query** - Execute any supported Cosmos SDK query
|
|
95
|
+
3. **cosmos_tx** - Execute any supported Cosmos SDK transaction
|
|
96
|
+
4. **list_modules** - List available query and transaction modules
|
|
97
|
+
5. **list_module_subcommands** - List subcommands for a specific module
|
|
98
|
+
|
|
99
|
+
## Supported Operations
|
|
100
|
+
|
|
101
|
+
### Query Modules
|
|
102
|
+
|
|
103
|
+
| Module | Subcommands |
|
|
104
|
+
|--------|-------------|
|
|
105
|
+
| bank | balance, balances, spendable-balances, total-supply (alias: total), supply-of, params, denom-metadata, denoms-metadata, send-enabled |
|
|
106
|
+
| staking | delegation, delegations, unbonding-delegation, unbonding-delegations, redelegations, validator, validators, validator-delegations, validator-unbonding-delegations, pool, params, historical-info |
|
|
107
|
+
| distribution | rewards, commission, community-pool, params, validator-outstanding-rewards, slashes, delegator-validators, delegator-withdraw-address |
|
|
108
|
+
| gov | proposal, proposals, vote, votes, deposit, deposits, tally, params |
|
|
109
|
+
| auth | account, accounts, params, module-accounts, module-account-by-name, address-bytes-to-string, address-string-to-bytes, bech32-prefix, account-info |
|
|
110
|
+
| billing | params, lease, leases, leases-by-tenant, leases-by-provider, leases-by-sku, credit-account, credit-accounts, credit-address, withdrawable-amount, provider-withdrawable, credit-estimate |
|
|
111
|
+
|
|
112
|
+
### Transaction Modules
|
|
113
|
+
|
|
114
|
+
| Module | Subcommands |
|
|
115
|
+
|--------|-------------|
|
|
116
|
+
| bank | send, multi-send |
|
|
117
|
+
| staking | delegate, unbond (alias: undelegate), redelegate |
|
|
118
|
+
| distribution | withdraw-rewards, set-withdraw-addr, fund-community-pool |
|
|
119
|
+
| gov | vote, weighted-vote, deposit |
|
|
120
|
+
| billing | fund-credit, create-lease, close-lease, withdraw |
|
|
121
|
+
| manifest | payout, burn-held-balance |
|
|
122
|
+
|
|
123
|
+
## Configuration
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
interface ManifestMCPConfig {
|
|
127
|
+
chainId: string; // Chain ID (e.g., "manifest-ledger-testnet")
|
|
128
|
+
rpcUrl: string; // RPC endpoint URL
|
|
129
|
+
gasPrice: string; // Gas price with denomination (e.g., "1.0umfx")
|
|
130
|
+
gasAdjustment?: number; // Gas adjustment multiplier (default: 1.3)
|
|
131
|
+
addressPrefix?: string; // Address prefix (default: "manifest")
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Wallet Provider Interface
|
|
136
|
+
|
|
137
|
+
Any wallet that provides an `OfflineSigner` can be used:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
interface WalletProvider {
|
|
141
|
+
getAddress(): Promise<string>;
|
|
142
|
+
getSigner(): Promise<OfflineSigner>;
|
|
143
|
+
connect?(): Promise<void>;
|
|
144
|
+
disconnect?(): Promise<void>;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### MnemonicWalletProvider
|
|
149
|
+
|
|
150
|
+
Built-in provider for testing or non-interactive environments:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { MnemonicWalletProvider } from '@manifest-network/manifest-mcp-browser';
|
|
154
|
+
|
|
155
|
+
const wallet = new MnemonicWalletProvider(config, mnemonic);
|
|
156
|
+
await wallet.connect();
|
|
157
|
+
const address = await wallet.getAddress();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Direct CosmJS Usage
|
|
161
|
+
|
|
162
|
+
You can also use the CosmJS client manager directly:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import {
|
|
166
|
+
CosmosClientManager,
|
|
167
|
+
cosmosQuery,
|
|
168
|
+
cosmosTx,
|
|
169
|
+
} from '@manifest-network/manifest-mcp-browser';
|
|
170
|
+
|
|
171
|
+
const clientManager = CosmosClientManager.getInstance(config, walletProvider);
|
|
172
|
+
|
|
173
|
+
// Query balance
|
|
174
|
+
const balance = await cosmosQuery(
|
|
175
|
+
clientManager,
|
|
176
|
+
'bank',
|
|
177
|
+
'balance',
|
|
178
|
+
['manifest1...', 'umfx']
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
// Send tokens
|
|
182
|
+
const result = await cosmosTx(
|
|
183
|
+
clientManager,
|
|
184
|
+
'bank',
|
|
185
|
+
'send',
|
|
186
|
+
['manifest1recipient...', '1000umfx'],
|
|
187
|
+
true // wait for confirmation
|
|
188
|
+
);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Differences from manifest-mcp
|
|
192
|
+
|
|
193
|
+
| Feature | manifest-mcp | @manifest-network/manifest-mcp-browser |
|
|
194
|
+
|---------|--------------|---------------------|
|
|
195
|
+
| Runtime | Node.js only | Browser + Node.js |
|
|
196
|
+
| Blockchain access | CLI (manifestd) | CosmJS/HTTP |
|
|
197
|
+
| Module discovery | Dynamic (CLI help) | Static registry |
|
|
198
|
+
| Manifest modules | Full support | Full support (manifestjs) |
|
|
199
|
+
|
|
200
|
+
## Error Handling
|
|
201
|
+
|
|
202
|
+
All errors are wrapped in `ManifestMCPError` with typed error codes:
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from '@manifest-network/manifest-mcp-browser';
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
await cosmosTx(clientManager, 'bank', 'send', ['...', '1000umfx']);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (error instanceof ManifestMCPError) {
|
|
211
|
+
console.log(error.code); // e.g., "TX_FAILED"
|
|
212
|
+
console.log(error.message); // Human-readable message with hints
|
|
213
|
+
console.log(error.details); // Additional context
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Error Codes
|
|
219
|
+
|
|
220
|
+
| Code | Description |
|
|
221
|
+
|------|-------------|
|
|
222
|
+
| `INVALID_CONFIG` | Configuration validation failed |
|
|
223
|
+
| `INVALID_ADDRESS` | Bech32 address validation failed |
|
|
224
|
+
| `INVALID_MNEMONIC` | Invalid mnemonic phrase |
|
|
225
|
+
| `TX_FAILED` | Transaction failed (invalid format, validation error) |
|
|
226
|
+
| `TX_BROADCAST_FAILED` | Transaction broadcast failed |
|
|
227
|
+
| `QUERY_FAILED` | Query failed (invalid args, RPC error) |
|
|
228
|
+
| `UNSUPPORTED_TX` | Unsupported transaction module/subcommand |
|
|
229
|
+
| `UNSUPPORTED_QUERY` | Unsupported query module/subcommand |
|
|
230
|
+
| `RPC_CONNECTION_FAILED` | Failed to connect to RPC endpoint |
|
|
231
|
+
| `WALLET_NOT_CONNECTED` | Wallet not connected or disconnected |
|
|
232
|
+
|
|
233
|
+
## CORS Requirements
|
|
234
|
+
|
|
235
|
+
The RPC endpoint must allow cross-origin requests for browser usage. If you encounter CORS errors, you may need to:
|
|
236
|
+
|
|
237
|
+
1. Use an RPC endpoint that allows CORS
|
|
238
|
+
2. Set up a CORS proxy
|
|
239
|
+
3. Configure your own RPC node to allow CORS
|
|
240
|
+
|
|
241
|
+
## Security
|
|
242
|
+
|
|
243
|
+
### Key Handling
|
|
244
|
+
|
|
245
|
+
This MCP server is wallet-agnostic. Security depends on the wallet provider you use:
|
|
246
|
+
|
|
247
|
+
- **cosmos-kit / Keplr / Leap**: Private keys stay in the wallet extension
|
|
248
|
+
- **Web3Auth**: Keys are reconstructed client-side using MPC
|
|
249
|
+
- **MnemonicWalletProvider**: Mnemonic stored in memory (for testing only)
|
|
250
|
+
|
|
251
|
+
### MnemonicWalletProvider Security
|
|
252
|
+
|
|
253
|
+
- Mnemonic is stored in memory during the wallet's lifetime
|
|
254
|
+
- Calling `disconnect()` clears the mnemonic and prevents reconnection
|
|
255
|
+
- After disconnect, create a new instance if needed
|
|
256
|
+
- Not recommended for production browser applications
|
|
257
|
+
|
|
258
|
+
### Input Validation
|
|
259
|
+
|
|
260
|
+
All inputs are validated to prevent common attack vectors:
|
|
261
|
+
|
|
262
|
+
- **Address validation**: Bech32 format validated using `@cosmjs/encoding`
|
|
263
|
+
- **Amount format**: Must be `<number><denom>` (e.g., `1000000umfx`)
|
|
264
|
+
- **Memo length**: Limited to 256 characters (Cosmos SDK default)
|
|
265
|
+
- **Args count**: Limited to 100 arguments per call
|
|
266
|
+
- **BigInt parsing**: Empty strings rejected (prevents silent 0n values)
|
|
267
|
+
- **Hex strings**: Validated format and length for address-bytes queries
|
|
268
|
+
|
|
269
|
+
### Resource Limits
|
|
270
|
+
|
|
271
|
+
Built-in protections against resource exhaustion:
|
|
272
|
+
|
|
273
|
+
- **Pagination**: All list queries default to 100 items max
|
|
274
|
+
- **Broadcast timeout**: Transactions timeout after 60 seconds
|
|
275
|
+
- **Poll interval**: Transaction confirmation polled every 3 seconds
|
|
276
|
+
|
|
277
|
+
### Best Practices
|
|
278
|
+
|
|
279
|
+
1. **Use wallet adapters in browsers** - Let users control their own keys via cosmos-kit, Web3Auth, etc.
|
|
280
|
+
2. **Never hardcode mnemonics** - Use environment variables or secure vaults for testing
|
|
281
|
+
3. **Call disconnect() when done** - Ensures sensitive data is cleared from memory
|
|
282
|
+
4. **Use HTTPS RPC endpoints** - Prevent man-in-the-middle attacks
|
|
283
|
+
|
|
284
|
+
### Error Response Sanitization
|
|
285
|
+
|
|
286
|
+
Error responses automatically redact sensitive fields to prevent accidental exposure:
|
|
287
|
+
- Fields named `mnemonic`, `privateKey`, `secret`, `password`, `seed`, `key`, `token`, `apiKey` are replaced with `[REDACTED]`
|
|
288
|
+
- Strings that appear to be mnemonics (12 or 24 words) are replaced with `[REDACTED - possible mnemonic]`
|
|
289
|
+
|
|
290
|
+
### Browser Security Considerations
|
|
291
|
+
|
|
292
|
+
- This package makes RPC calls to blockchain nodes - ensure you trust the RPC endpoint
|
|
293
|
+
- In browser environments, use HTTPS RPC endpoints to prevent MITM attacks
|
|
294
|
+
- Consider Content Security Policy (CSP) headers to restrict allowed endpoints
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEzE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,YAAY,EAAE,iBAAiB,CAAC,CAYlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAwB;AACxB,OAAO,EAOL,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,8BAA8B;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,iBAAiB;AACjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,kCAAkC;AAClC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEpD,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,aAAa;AACb,OAAO,EAAE,iBAAiB,EAA4B,MAAM,YAAY,CAAC;AAEzE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAO1C;IACC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;IACzD,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAExE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAI,sBAAsB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACvE,MAAM,cAAc,CAAC,OAAO,EAAE,CAAC;IAE/B,OAAO,IAAI,iBAAiB,CAAC;QAC3B,MAAM,EAAE,SAAS;QACjB,cAAc;KACf,CAAC,CAAC;AACL,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SigningStargateClient } from '@cosmjs/stargate';
|
|
2
|
+
import { liftedinit } from '@manifest-network/manifestjs';
|
|
3
|
+
import { ManifestMCPConfig, WalletProvider } from './types.js';
|
|
4
|
+
export type ManifestQueryClient = Awaited<ReturnType<typeof liftedinit.ClientFactory.createRPCQueryClient>>;
|
|
5
|
+
/**
|
|
6
|
+
* Manages CosmJS client instances with lazy initialization and singleton pattern
|
|
7
|
+
*/
|
|
8
|
+
export declare class CosmosClientManager {
|
|
9
|
+
private static instances;
|
|
10
|
+
private config;
|
|
11
|
+
private walletProvider;
|
|
12
|
+
private queryClient;
|
|
13
|
+
private signingClient;
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Get or create a singleton instance for the given config
|
|
17
|
+
*/
|
|
18
|
+
static getInstance(config: ManifestMCPConfig, walletProvider: WalletProvider): CosmosClientManager;
|
|
19
|
+
/**
|
|
20
|
+
* Clear all cached instances (useful for testing or reconnection)
|
|
21
|
+
*/
|
|
22
|
+
static clearInstances(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the manifestjs RPC query client with all module extensions
|
|
25
|
+
*/
|
|
26
|
+
getQueryClient(): Promise<ManifestQueryClient>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a signing client with all Manifest registries (for transactions)
|
|
29
|
+
*/
|
|
30
|
+
getSigningClient(): Promise<SigningStargateClient>;
|
|
31
|
+
/**
|
|
32
|
+
* Get the wallet address
|
|
33
|
+
*/
|
|
34
|
+
getAddress(): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the configuration
|
|
37
|
+
*/
|
|
38
|
+
getConfig(): ManifestMCPConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Disconnect all clients
|
|
41
|
+
*/
|
|
42
|
+
disconnect(): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA0B,MAAM,kBAAkB,CAAC;AACjF,OAAO,EASL,UAAU,EACX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAA0C,MAAM,YAAY,CAAC;AAIvG,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC;AA6B5G;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAA+C;IAEvE,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,aAAa,CAAsC;IAE3D,OAAO;IAKP;;OAEG;IACH,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,iBAAiB,EACzB,cAAc,EAAE,cAAc,GAC7B,mBAAmB;IAYtB;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,IAAI;IAI7B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAkBpD;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAyCxD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;OAEG;IACH,SAAS,IAAI,iBAAiB;IAI9B;;OAEG;IACH,UAAU,IAAI,IAAI;CAOnB"}
|