@abstract-foundation/agw-mcp 0.1.0-beta.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 +21 -0
- package/README.md +159 -0
- package/dist/ccip-BoY3djaA.mjs +155 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +22548 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Abstract Foundation
|
|
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,159 @@
|
|
|
1
|
+
# @abstract-foundation/agw-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@abstract-foundation/agw-mcp)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/Abstract-Foundation/agw-mcp/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
MCP server for [Abstract Global Wallet](https://abs.xyz) session-key workflows — scoped wallet actions without custodial signing.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx -y @abstract-foundation/agw-mcp serve --chain-id 11124
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or add it to Claude Code directly:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
claude mcp add agw -- npx -y @abstract-foundation/agw-mcp serve --chain-id 11124
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
### 1. Bootstrap a session
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx -y @abstract-foundation/agw-mcp init --chain-id 11124
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This opens the companion app where you:
|
|
30
|
+
|
|
31
|
+
1. Choose a policy preset (or provide custom policy JSON)
|
|
32
|
+
2. Connect your Abstract Global Wallet
|
|
33
|
+
3. Approve the session key
|
|
34
|
+
|
|
35
|
+
Session data is saved to `~/.agw-mcp/session.json` with `0o600` file permissions. The session signer key is stored separately in `~/.agw-mcp/session-signer.key`.
|
|
36
|
+
|
|
37
|
+
### 2. Start the MCP server
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx -y @abstract-foundation/agw-mcp serve --chain-id 11124
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Client Configuration
|
|
44
|
+
|
|
45
|
+
### Claude Code
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
claude mcp add agw -- npx -y @abstract-foundation/agw-mcp serve --chain-id 11124
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Claude Desktop
|
|
52
|
+
|
|
53
|
+
Add to your `claude_desktop_config.json`:
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>macOS: ~/Library/Application Support/Claude/claude_desktop_config.json</summary>
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"agw-mcp": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["-y", "@abstract-foundation/agw-mcp", "serve", "--chain-id", "11124"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
</details>
|
|
70
|
+
|
|
71
|
+
<details>
|
|
72
|
+
<summary>Windows: %APPDATA%\Claude\claude_desktop_config.json</summary>
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"agw-mcp": {
|
|
78
|
+
"command": "npx",
|
|
79
|
+
"args": ["-y", "@abstract-foundation/agw-mcp", "serve", "--chain-id", "11124"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
</details>
|
|
86
|
+
|
|
87
|
+
### Cursor / Windsurf
|
|
88
|
+
|
|
89
|
+
Use the same JSON block as Claude Desktop in your editor's MCP configuration file.
|
|
90
|
+
|
|
91
|
+
### Generate config snippet
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx -y @abstract-foundation/agw-mcp config --npx --chain-id 11124
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tools
|
|
98
|
+
|
|
99
|
+
| Tool | Description |
|
|
100
|
+
|------|-------------|
|
|
101
|
+
| `get_wallet_address` | Returns AGW account address from local session |
|
|
102
|
+
| `get_balances` | Native + ERC-20 balances with formatted amounts |
|
|
103
|
+
| `get_token_list` | Wallet ERC-20 holdings via network discovery |
|
|
104
|
+
| `get_session_status` | On-chain session state + local expiry metadata |
|
|
105
|
+
| `sign_message` | Signs UTF-8 message via session signer |
|
|
106
|
+
| `sign_transaction` | Signs EVM transaction, returns signed payload (no broadcast) |
|
|
107
|
+
| `preview_transaction` | Impact/risk preview without signing |
|
|
108
|
+
| `send_transaction` | Preview by default, broadcast on `execute: true` |
|
|
109
|
+
| `send_calls` | EIP-5792 batch call execution |
|
|
110
|
+
| `transfer_token` | Native/ERC-20 transfer with policy checks |
|
|
111
|
+
| `swap_tokens` | 0x quote + execute via session key |
|
|
112
|
+
| `write_contract` | Contract write with target/selector policy validation |
|
|
113
|
+
| `deploy_contract` | Contract deployment with ABI/bytecode validation |
|
|
114
|
+
| `revoke_session` | Revoke session key, invalidate local session |
|
|
115
|
+
|
|
116
|
+
## Network Configuration
|
|
117
|
+
|
|
118
|
+
Defaults to Abstract testnet (chain ID `11124`). Switch to mainnet or override RPC:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Mainnet
|
|
122
|
+
npx -y @abstract-foundation/agw-mcp serve --chain-id 2741
|
|
123
|
+
|
|
124
|
+
# Custom RPC
|
|
125
|
+
npx -y @abstract-foundation/agw-mcp serve --chain-id 2741 --rpc-url https://api.mainnet.abs.xyz
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Environment variables are also supported:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
AGW_MCP_CHAIN_ID=2741 npx -y @abstract-foundation/agw-mcp serve
|
|
132
|
+
AGW_MCP_RPC_URL=https://api.mainnet.abs.xyz npx -y @abstract-foundation/agw-mcp serve
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Security Model
|
|
136
|
+
|
|
137
|
+
- **Non-custodial**: Session keys are scoped and time-limited. No full wallet access.
|
|
138
|
+
- **Default-deny policies**: Write tools fail unless a matching policy explicitly allows the target address, function selector, or transfer amount.
|
|
139
|
+
- **Local-only transport**: stdio MCP — no network exposure. Session signer keys never leave the machine.
|
|
140
|
+
- **Restrictive file permissions**: Session storage directory `0o700`, files `0o600`.
|
|
141
|
+
- **Stderr-only logging**: stdout is reserved for MCP stdio transport. All operational logs go to stderr.
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
git clone https://github.com/Abstract-Foundation/agw-mcp.git
|
|
147
|
+
cd agw-mcp
|
|
148
|
+
pnpm install
|
|
149
|
+
pnpm build
|
|
150
|
+
|
|
151
|
+
pnpm dev # tsx dev mode
|
|
152
|
+
pnpm test # jest
|
|
153
|
+
pnpm check-types # tsc --noEmit
|
|
154
|
+
pnpm lint # eslint
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { a as HttpRequestError, c as decodeErrorResult, d as isHex, f as BaseError, i as isAddressEqual, l as encodeAbiParameters, n as localBatchGatewayUrl, o as getUrl, r as call, s as stringify, t as localBatchGatewayRequest, u as concat } from "./index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/viem/_esm/errors/ccip.js
|
|
4
|
+
var OffchainLookupError = class extends BaseError {
|
|
5
|
+
constructor({ callbackSelector, cause, data, extraData, sender, urls }) {
|
|
6
|
+
super(cause.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
7
|
+
cause,
|
|
8
|
+
metaMessages: [
|
|
9
|
+
...cause.metaMessages || [],
|
|
10
|
+
cause.metaMessages?.length ? "" : [],
|
|
11
|
+
"Offchain Gateway Call:",
|
|
12
|
+
urls && [" Gateway URL(s):", ...urls.map((url) => ` ${getUrl(url)}`)],
|
|
13
|
+
` Sender: ${sender}`,
|
|
14
|
+
` Data: ${data}`,
|
|
15
|
+
` Callback selector: ${callbackSelector}`,
|
|
16
|
+
` Extra data: ${extraData}`
|
|
17
|
+
].flat(),
|
|
18
|
+
name: "OffchainLookupError"
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var OffchainLookupResponseMalformedError = class extends BaseError {
|
|
23
|
+
constructor({ result, url }) {
|
|
24
|
+
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
25
|
+
metaMessages: [`Gateway URL: ${getUrl(url)}`, `Response: ${stringify(result)}`],
|
|
26
|
+
name: "OffchainLookupResponseMalformedError"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var OffchainLookupSenderMismatchError = class extends BaseError {
|
|
31
|
+
constructor({ sender, to }) {
|
|
32
|
+
super("Reverted sender address does not match target contract address (`to`).", {
|
|
33
|
+
metaMessages: [`Contract address: ${to}`, `OffchainLookup sender address: ${sender}`],
|
|
34
|
+
name: "OffchainLookupSenderMismatchError"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region node_modules/viem/_esm/utils/ccip.js
|
|
41
|
+
const offchainLookupSignature = "0x556f1830";
|
|
42
|
+
const offchainLookupAbiItem = {
|
|
43
|
+
name: "OffchainLookup",
|
|
44
|
+
type: "error",
|
|
45
|
+
inputs: [
|
|
46
|
+
{
|
|
47
|
+
name: "sender",
|
|
48
|
+
type: "address"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "urls",
|
|
52
|
+
type: "string[]"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "callData",
|
|
56
|
+
type: "bytes"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "callbackFunction",
|
|
60
|
+
type: "bytes4"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "extraData",
|
|
64
|
+
type: "bytes"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
|
|
69
|
+
const { args } = decodeErrorResult({
|
|
70
|
+
data,
|
|
71
|
+
abi: [offchainLookupAbiItem]
|
|
72
|
+
});
|
|
73
|
+
const [sender, urls, callData, callbackSelector, extraData] = args;
|
|
74
|
+
const { ccipRead } = client;
|
|
75
|
+
const ccipRequest_ = ccipRead && typeof ccipRead?.request === "function" ? ccipRead.request : ccipRequest;
|
|
76
|
+
try {
|
|
77
|
+
if (!isAddressEqual(to, sender)) throw new OffchainLookupSenderMismatchError({
|
|
78
|
+
sender,
|
|
79
|
+
to
|
|
80
|
+
});
|
|
81
|
+
const { data: data_ } = await call(client, {
|
|
82
|
+
blockNumber,
|
|
83
|
+
blockTag,
|
|
84
|
+
data: concat([callbackSelector, encodeAbiParameters([{ type: "bytes" }, { type: "bytes" }], [urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({
|
|
85
|
+
data: callData,
|
|
86
|
+
ccipRequest: ccipRequest_
|
|
87
|
+
}) : await ccipRequest_({
|
|
88
|
+
data: callData,
|
|
89
|
+
sender,
|
|
90
|
+
urls
|
|
91
|
+
}), extraData])]),
|
|
92
|
+
to
|
|
93
|
+
});
|
|
94
|
+
return data_;
|
|
95
|
+
} catch (err) {
|
|
96
|
+
throw new OffchainLookupError({
|
|
97
|
+
callbackSelector,
|
|
98
|
+
cause: err,
|
|
99
|
+
data,
|
|
100
|
+
extraData,
|
|
101
|
+
sender,
|
|
102
|
+
urls
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function ccipRequest({ data, sender, urls }) {
|
|
107
|
+
let error = /* @__PURE__ */ new Error("An unknown error occurred.");
|
|
108
|
+
for (let i = 0; i < urls.length; i++) {
|
|
109
|
+
const url = urls[i];
|
|
110
|
+
const method = url.includes("{data}") ? "GET" : "POST";
|
|
111
|
+
const body = method === "POST" ? {
|
|
112
|
+
data,
|
|
113
|
+
sender
|
|
114
|
+
} : void 0;
|
|
115
|
+
const headers = method === "POST" ? { "Content-Type": "application/json" } : {};
|
|
116
|
+
try {
|
|
117
|
+
const response = await fetch(url.replace("{sender}", sender.toLowerCase()).replace("{data}", data), {
|
|
118
|
+
body: JSON.stringify(body),
|
|
119
|
+
headers,
|
|
120
|
+
method
|
|
121
|
+
});
|
|
122
|
+
let result;
|
|
123
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) result = (await response.json()).data;
|
|
124
|
+
else result = await response.text();
|
|
125
|
+
if (!response.ok) {
|
|
126
|
+
error = new HttpRequestError({
|
|
127
|
+
body,
|
|
128
|
+
details: result?.error ? stringify(result.error) : response.statusText,
|
|
129
|
+
headers: response.headers,
|
|
130
|
+
status: response.status,
|
|
131
|
+
url
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (!isHex(result)) {
|
|
136
|
+
error = new OffchainLookupResponseMalformedError({
|
|
137
|
+
result,
|
|
138
|
+
url
|
|
139
|
+
});
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
} catch (err) {
|
|
144
|
+
error = new HttpRequestError({
|
|
145
|
+
body,
|
|
146
|
+
details: err.message,
|
|
147
|
+
url
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { offchainLookup, offchainLookupSignature };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|