@wrenagent/mcp 0.0.0-stage → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wren contributors
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 CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # @wrenagent/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The [Wren](https://wrenagent.app) MCP server. It gives Claude, Cursor and any MCP client:
4
+
5
+ - **Live onchain market data** for Elysium, Base, Robinhood Chain, Solana and HyperEVM.
6
+ - **A honeypot check** you can run before buying a token.
7
+ - **Your Wren memory, vault and agents**, shared with the Wren app.
8
+
9
+ None of the tools can sign, send, swap or move funds.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npx -y -p @wrenagent/mcp@0.1.0 wren install
15
+ ```
16
+
17
+ This adds Wren to Claude Desktop, Cursor and Windsurf if they are installed. Restart the client afterwards.
18
+
19
+ **Claude Code**
20
+
21
+ ```bash
22
+ claude mcp add wren -s user -- npx -y -p @wrenagent/mcp@0.1.0 wren-mcp
23
+ ```
24
+
25
+ **Any other client:** add a stdio server named `wren` that runs `npx -y -p @wrenagent/mcp@0.1.0 wren-mcp`.
26
+
27
+ The install commands pin an exact version, so a new release never runs on your machine until you choose to update.
28
+
29
+ ## Sign in (memory, vault and agents)
30
+
31
+ The market and honeypot tools work without an account. The memory, vault and agent tools need an API key:
32
+
33
+ 1. Open [wrenagent.app → Connect MCP](https://wrenagent.app/app.html#/connect), sign in, and create a key.
34
+ 2. Run:
35
+
36
+ ```bash
37
+ npx -y -p @wrenagent/mcp@0.1.0 wren login
38
+ ```
39
+
40
+ The key is saved to `~/.wren/config.json` with file mode 600. Instead of logging in, you can set `WREN_API_KEY` in the client's MCP entry. `wren status` shows the account the MCP is signed in as, and `wren logout` removes the saved key.
41
+
42
+ ## Tools
43
+
44
+ | Tool | Key needed | What it does |
45
+ |---|---|---|
46
+ | `get_token` | no | Price, market cap, liquidity, volume and top pools for one token (GeckoTerminal, DexScreener, and Montra on Elysium). |
47
+ | `newest_tokens` | no | The newest pools or launches on a chain. |
48
+ | `check_token` | no | Honeypot and contract-risk screen. Base: GoPlus plus a honeypot.is sell simulation. Robinhood Chain and Solana: GoPlus. The verdict is `risky`, `caution`, `no_flags` or `unknown`. |
49
+ | `whoami` | yes | The Wren account the key belongs to. |
50
+ | `memory_add` / `memory_search` / `memory_delete` | yes | Facts saved here show up on the Memory page and in the Wren AI terminal. |
51
+ | `vault_list` / `vault_get` / `vault_save` / `vault_versions` | yes | Versioned documents. Every save keeps the previous version. |
52
+ | `agent_list` / `agent_create` / `agent_note` / `agent_notes` | yes | Agent records with a goal, a schedule and notes. |
53
+
54
+ ## Configuration
55
+
56
+ | Variable | Default | Purpose |
57
+ |---|---|---|
58
+ | `WREN_API_KEY` | from `wren login` | API key for the account tools. |
59
+ | `WREN_API_URL` | `https://api.wrenagent.app/api` | Wren server. Point it at your own server if you self-host. |
60
+ | `WREN_HOME` | `~/.wren` | Where `wren login` stores its config. |
61
+
62
+ ## Safety
63
+
64
+ - `check_token` is an automated screen. `no_flags` is not a guarantee, and nothing these tools return is financial advice.
65
+ - An API key can read and write your memory, vault and agents. It can never manage API keys or move funds from the app wallet. Revoke a key on the Connect MCP page at any time.
66
+
67
+ ## License
68
+
69
+ MIT
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { createServer } from '../src/server.js';
4
+
5
+ const server = createServer();
6
+ await server.connect(new StdioServerTransport());
package/bin/wren.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import readline from 'node:readline';
3
+ import { VERSION, PKG, DEFAULT_API, loadConfig, readFileConfig, writeFileConfig, configFile } from '../src/config.js';
4
+ import { accountClient } from '../src/api.js';
5
+ import { install, ENTRY } from '../src/install.js';
6
+
7
+ const [cmd = 'help', ...rest] = process.argv.slice(2);
8
+ const flag = (name) => { const i = rest.indexOf(`--${name}`); return i >= 0 ? rest[i + 1] : undefined; };
9
+ const run = `npx -y -p ${PKG}@${VERSION}`;
10
+
11
+ function ask(question) {
12
+ return new Promise((resolve) => {
13
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
14
+ rl.stdoutMuted = false;
15
+ rl._writeToOutput = function (s) { if (!rl.stdoutMuted || s.includes(question)) rl.output.write(s); };
16
+ rl.question(question, (a) => { rl.close(); process.stdout.write('\n'); resolve(a.trim()); });
17
+ rl.stdoutMuted = true;
18
+ });
19
+ }
20
+
21
+ async function main() {
22
+ switch (cmd) {
23
+ case 'install': {
24
+ const res = install();
25
+ for (const r of res) console.log(`${r.status === 'added' ? '✓' : '·'} ${r.name}: ${r.status}${r.status === 'added' ? ` (${r.file})` : ''}`);
26
+ console.log(`\nClaude Code:\n claude mcp add wren -s user -- ${ENTRY.command} ${ENTRY.args.join(' ')}`);
27
+ console.log(`\nVS Code, Zed and other clients: add a server named "wren" that runs\n ${ENTRY.command} ${ENTRY.args.join(' ')}`);
28
+ console.log(`\nRestart your client. Market and honeypot tools work right away; for memory, vault and agents run:\n ${run} wren login`);
29
+ return;
30
+ }
31
+ case 'login': {
32
+ const apiUrl = (flag('api') || loadConfig().apiUrl || DEFAULT_API).replace(/\/+$/, '');
33
+ const apiKey = process.env.WREN_API_KEY || await ask('Paste your Wren API key (wrenagent.app → Connect MCP → API keys): ');
34
+ if (!/^wren_sk_[A-Za-z0-9]{20,}$/.test(apiKey)) throw new Error('That does not look like a Wren API key (it starts with wren_sk_).');
35
+ const me = await accountClient({ apiUrl, apiKey }).me();
36
+ const file = writeFileConfig({ ...readFileConfig(), apiUrl, apiKey });
37
+ console.log(`Signed in as ${me?.user?.address || me?.address || 'your Wren account'}. Saved to ${file}`);
38
+ return;
39
+ }
40
+ case 'logout': {
41
+ const { apiKey, ...restCfg } = readFileConfig();
42
+ writeFileConfig(restCfg);
43
+ console.log(apiKey ? `Removed the API key from ${configFile()}` : 'No saved API key.');
44
+ return;
45
+ }
46
+ case 'status': {
47
+ const cfg = loadConfig();
48
+ console.log(`${PKG} ${VERSION}\nServer: ${cfg.apiUrl}`);
49
+ if (!cfg.apiKey) { console.log(`Account: not signed in (run: ${run} wren login)`); return; }
50
+ try { const me = await accountClient(cfg).me(); console.log(`Account: ${me?.user?.address || me?.address || 'signed in'}`); }
51
+ catch (e) { console.log(`Account: key rejected or server unreachable (${e.message})`); process.exitCode = 1; }
52
+ return;
53
+ }
54
+ case 'version': case '--version': case '-v':
55
+ console.log(VERSION); return;
56
+ default:
57
+ console.log(`Wren MCP ${VERSION}
58
+
59
+ Usage: ${run} wren <command>
60
+
61
+ install Add Wren to Claude Desktop, Cursor and Windsurf (prints the Claude Code command)
62
+ login Save an API key so memory, vault and agent tools act as your account
63
+ logout Remove the saved API key
64
+ status Show the server and the signed-in account
65
+ version Print the version
66
+
67
+ The MCP server itself runs as: ${run} wren-mcp
68
+ Docs: https://wrenagent.app/docs.html`);
69
+ }
70
+ }
71
+
72
+ main().catch((e) => { console.error(`wren: ${e.message}`); process.exit(1); });
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@wrenagent/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Wren MCP server: live onchain market data, honeypot checks, and your Wren memory, vault and agents in Claude, Cursor and any MCP client.",
5
+ "type": "module",
6
+ "bin": {
7
+ "wren": "bin/wren.js",
8
+ "wren-mcp": "bin/wren-mcp.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "src",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=20"
18
+ },
19
+ "scripts": {
20
+ "test": "node --test \"test/*.test.js\""
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "model-context-protocol",
25
+ "claude",
26
+ "cursor",
27
+ "crypto",
28
+ "onchain",
29
+ "base",
30
+ "solana",
31
+ "robinhood-chain",
32
+ "honeypot"
33
+ ],
34
+ "homepage": "https://wrenagent.app",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/wrenagent-app/wren.git",
38
+ "directory": "mcp"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/wrenagent-app/wren/issues"
42
+ },
43
+ "license": "MIT",
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "provenance": true
47
+ },
48
+ "dependencies": {
49
+ "@modelcontextprotocol/sdk": "1.32.2",
50
+ "zod": "4.6.7"
51
+ }
52
+ }
package/src/api.js ADDED
@@ -0,0 +1,31 @@
1
+ // Client for your Wren account (memory, vault, agents). Needs an API key from wrenagent.app → Connect MCP.
2
+ import { fetchJson } from './http.js';
3
+
4
+ export class NoKeyError extends Error {
5
+ constructor() {
6
+ super('No Wren API key. Create one at https://wrenagent.app/app.html#/connect, then run `npx -y -p @wrenagent/mcp wren login` or set WREN_API_KEY.');
7
+ }
8
+ }
9
+
10
+ export function accountClient(cfg) {
11
+ const call = (method, p, body) => {
12
+ if (!cfg.apiKey) throw new NoKeyError();
13
+ return fetchJson(cfg.apiUrl + p, { method, body, headers: { authorization: `Bearer ${cfg.apiKey}` } });
14
+ };
15
+ const q = (o) => { const s = new URLSearchParams(Object.entries(o).filter(([, v]) => v !== undefined && v !== '')).toString(); return s ? `?${s}` : ''; };
16
+ return {
17
+ me: () => call('GET', '/me'),
18
+ memoryAdd: ({ text, tags }) => call('POST', '/memory', { text, tags }),
19
+ memorySearch: ({ query, tag, limit }) => call('GET', '/memory' + q({ q: query, tag, limit })),
20
+ memoryDelete: ({ id }) => call('DELETE', `/memory/${encodeURIComponent(id)}`),
21
+ vaultList: ({ query, limit }) => call('GET', '/vault' + q({ q: query, limit })),
22
+ vaultGet: ({ id }) => call('GET', `/vault/${encodeURIComponent(id)}`),
23
+ vaultCreate: ({ title, content }) => call('POST', '/vault', { title, content }),
24
+ vaultUpdate: ({ id, title, content, note }) => call('PUT', `/vault/${encodeURIComponent(id)}`, { title, content, note }),
25
+ vaultVersions: ({ id }) => call('GET', `/vault/${encodeURIComponent(id)}/versions`),
26
+ agentList: () => call('GET', '/agents'),
27
+ agentCreate: ({ name, goal, schedule }) => call('POST', '/agents', { name, goal, schedule }),
28
+ agentNote: ({ id, text, kind }) => call('POST', `/agents/${encodeURIComponent(id)}/notes`, { text, kind }),
29
+ agentNotes: ({ id }) => call('GET', `/agents/${encodeURIComponent(id)}/notes`),
30
+ };
31
+ }
package/src/config.js ADDED
@@ -0,0 +1,33 @@
1
+ // Settings come from the environment first, then ~/.wren/config.json (written by `wren login`).
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+
6
+ export const VERSION = '0.1.0';
7
+ export const PKG = '@wrenagent/mcp';
8
+ export const DEFAULT_API = 'https://api.wrenagent.app/api';
9
+
10
+ export function configDir(env = process.env) {
11
+ return env.WREN_HOME || path.join(os.homedir(), '.wren');
12
+ }
13
+ export const configFile = (env = process.env) => path.join(configDir(env), 'config.json');
14
+
15
+ export function readFileConfig(env = process.env) {
16
+ try { return JSON.parse(fs.readFileSync(configFile(env), 'utf8')) || {}; } catch { return {}; }
17
+ }
18
+
19
+ export function writeFileConfig(data, env = process.env) {
20
+ fs.mkdirSync(configDir(env), { recursive: true, mode: 0o700 });
21
+ const file = configFile(env);
22
+ fs.writeFileSync(file, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
23
+ try { fs.chmodSync(file, 0o600); } catch { /* not supported on this platform */ }
24
+ return file;
25
+ }
26
+
27
+ export function loadConfig(env = process.env) {
28
+ const f = readFileConfig(env);
29
+ return {
30
+ apiUrl: (env.WREN_API_URL || f.apiUrl || DEFAULT_API).replace(/\/+$/, ''),
31
+ apiKey: env.WREN_API_KEY || f.apiKey || '',
32
+ };
33
+ }
package/src/http.js ADDED
@@ -0,0 +1,20 @@
1
+ // Small fetch wrapper. globalThis.fetch is resolved at call time so tests can replace it.
2
+ export async function fetchJson(url, { method = 'GET', body, headers = {}, timeoutMs = 15000 } = {}) {
3
+ const res = await globalThis.fetch(url, {
4
+ method,
5
+ headers: { accept: 'application/json', 'user-agent': 'wren-mcp/0.1', ...(body !== undefined ? { 'content-type': 'application/json' } : {}), ...headers },
6
+ body: body !== undefined ? JSON.stringify(body) : undefined,
7
+ signal: AbortSignal.timeout(timeoutMs),
8
+ });
9
+ const text = await res.text();
10
+ let json = null;
11
+ try { json = text ? JSON.parse(text) : null; } catch { /* not JSON */ }
12
+ if (!res.ok) {
13
+ const msg = json?.message || (typeof json?.error === 'string' ? json.error : '') || text.slice(0, 200);
14
+ const err = new Error(`${new URL(url).host} responded ${res.status}${msg ? `: ${msg}` : ''}`);
15
+ err.status = res.status;
16
+ err.code = json?.error;
17
+ throw err;
18
+ }
19
+ return json;
20
+ }
package/src/install.js ADDED
@@ -0,0 +1,36 @@
1
+ // Adds Wren to the MCP config of desktop clients that are installed on this machine.
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { PKG, VERSION } from './config.js';
6
+
7
+ export const ENTRY = { command: 'npx', args: ['-y', '-p', `${PKG}@${VERSION}`, 'wren-mcp'] };
8
+
9
+ export function clientPaths({ home = os.homedir(), platform = process.platform, env = process.env } = {}) {
10
+ const appData = env.APPDATA || path.join(home, 'AppData', 'Roaming');
11
+ const claudeDir = platform === 'darwin' ? path.join(home, 'Library', 'Application Support', 'Claude')
12
+ : platform === 'win32' ? path.join(appData, 'Claude') : path.join(home, '.config', 'Claude');
13
+ return [
14
+ { name: 'Claude Desktop', dir: claudeDir, file: path.join(claudeDir, 'claude_desktop_config.json') },
15
+ { name: 'Cursor', dir: path.join(home, '.cursor'), file: path.join(home, '.cursor', 'mcp.json') },
16
+ { name: 'Windsurf', dir: path.join(home, '.codeium', 'windsurf'), file: path.join(home, '.codeium', 'windsurf', 'mcp_config.json') },
17
+ ];
18
+ }
19
+
20
+ /** Writes the "wren" entry into each detected client's mcpServers. Keeps every other entry and backs the file up first. */
21
+ export function install(opts = {}) {
22
+ const results = [];
23
+ for (const c of clientPaths(opts)) {
24
+ if (!fs.existsSync(c.dir)) { results.push({ ...c, status: 'not found' }); continue; }
25
+ let json = {};
26
+ if (fs.existsSync(c.file)) {
27
+ const raw = fs.readFileSync(c.file, 'utf8');
28
+ try { json = raw.trim() ? JSON.parse(raw) : {}; } catch { results.push({ ...c, status: 'skipped: config is not valid JSON' }); continue; }
29
+ fs.writeFileSync(c.file + '.bak', raw);
30
+ }
31
+ json.mcpServers = { ...(json.mcpServers || {}), wren: ENTRY };
32
+ fs.writeFileSync(c.file, JSON.stringify(json, null, 2) + '\n');
33
+ results.push({ ...c, status: 'added' });
34
+ }
35
+ return results;
36
+ }
package/src/market.js ADDED
@@ -0,0 +1,127 @@
1
+ // Read-only market data and token safety checks. No key needed, nothing here can sign or move funds.
2
+ import { fetchJson } from './http.js';
3
+
4
+ export const CHAINS = {
5
+ ely: { name: 'Elysium', family: 'evm', gecko: 'elysium' },
6
+ base: { name: 'Base', family: 'evm', gecko: 'base', dexscreener: 'base', goplus: '8453', honeypotIs: 8453 },
7
+ rh: { name: 'Robinhood Chain', family: 'evm', gecko: 'robinhood', dexscreener: 'robinhood', goplus: '4663' },
8
+ sol: { name: 'Solana', family: 'sol', gecko: 'solana', dexscreener: 'solana' },
9
+ hyp: { name: 'HyperEVM', family: 'evm', gecko: 'hyperevm', dexscreener: 'hyperevm' },
10
+ };
11
+ export const CHAIN_IDS = Object.keys(CHAINS);
12
+
13
+ const API = {
14
+ gecko: 'https://api.geckoterminal.com/api/v2',
15
+ dexscreener: 'https://api.dexscreener.com',
16
+ montra: 'https://api.montramarkets.xyz',
17
+ goplus: 'https://api.gopluslabs.io/api/v1',
18
+ honeypot: 'https://api.honeypot.is/v2',
19
+ };
20
+
21
+ const pick = (o, keys) => Object.fromEntries(keys.filter((k) => o && o[k] !== undefined && o[k] !== null).map((k) => [k, o[k]]));
22
+
23
+ export function checkAddress(chain, address) {
24
+ const a = String(address || '').trim();
25
+ const ok = CHAINS[chain].family === 'sol' ? /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(a) : /^0x[0-9a-fA-F]{40}$/.test(a);
26
+ if (!ok) throw new Error(`"${address}" is not a valid ${CHAINS[chain].name} token address`);
27
+ return a;
28
+ }
29
+
30
+ export async function getToken({ chain, address }) {
31
+ const c = CHAINS[chain];
32
+ const a = checkAddress(chain, address);
33
+ const out = { chain, address: a, sources: {} };
34
+ const jobs = [
35
+ fetchJson(`${API.gecko}/networks/${c.gecko}/tokens/${a}?include=top_pools`).then((j) => {
36
+ const t = j?.data?.attributes || {};
37
+ out.sources.geckoterminal = {
38
+ ...pick(t, ['name', 'symbol', 'price_usd', 'fdv_usd', 'market_cap_usd', 'total_reserve_in_usd', 'volume_usd']),
39
+ top_pools: (j?.included || []).filter((x) => x.type === 'pool').slice(0, 3).map((p) => pick(p.attributes, ['address', 'name', 'reserve_in_usd', 'price_change_percentage', 'pool_created_at'])),
40
+ };
41
+ }).catch((e) => { out.sources.geckoterminal = { error: e.message }; }),
42
+ ];
43
+ if (c.dexscreener) {
44
+ jobs.push(fetchJson(`${API.dexscreener}/tokens/v1/${c.dexscreener}/${a}`).then((j) => {
45
+ const pairs = Array.isArray(j) ? j : j?.pairs || [];
46
+ out.sources.dexscreener = pairs.slice(0, 3).map((p) => pick(p, ['dexId', 'pairAddress', 'priceUsd', 'liquidity', 'volume', 'priceChange', 'fdv', 'marketCap', 'pairCreatedAt', 'url']));
47
+ }).catch((e) => { out.sources.dexscreener = { error: e.message }; }));
48
+ }
49
+ if (chain === 'ely') {
50
+ jobs.push(fetchJson(`${API.montra}/api/tokens/${a}`).then((j) => {
51
+ out.sources.montra = pick(j?.token || j, ['name', 'symbol', 'priceUsd', 'marketCapUsd', 'volume24hUsd', 'change24hPct', 'holders', 'launchedAt']);
52
+ }).catch((e) => { out.sources.montra = { error: e.message }; }));
53
+ }
54
+ await Promise.all(jobs);
55
+ return out;
56
+ }
57
+
58
+ export async function newestTokens({ chain, limit = 20 }) {
59
+ const n = Math.max(1, Math.min(50, limit));
60
+ if (chain === 'ely') {
61
+ const j = await fetchJson(`${API.montra}/api/tokens?sort=new`);
62
+ return { chain, source: 'montra', tokens: (j?.tokens || []).slice(0, n).map((t) => pick(t, ['address', 'name', 'symbol', 'priceUsd', 'marketCapUsd', 'volume24hUsd', 'holders', 'launchedAt'])) };
63
+ }
64
+ const j = await fetchJson(`${API.gecko}/networks/${CHAINS[chain].gecko}/new_pools?page=1`);
65
+ return {
66
+ chain, source: 'geckoterminal',
67
+ pools: (j?.data || []).slice(0, n).map((p) => {
68
+ const a = p.attributes || {};
69
+ return {
70
+ pool: a.address, name: a.name, created_at: a.pool_created_at,
71
+ token: p.relationships?.base_token?.data?.id?.split('_').slice(1).join('_'),
72
+ price_usd: a.base_token_price_usd, fdv_usd: a.fdv_usd, liquidity_usd: a.reserve_in_usd, volume_usd_24h: a.volume_usd?.h24,
73
+ };
74
+ }),
75
+ };
76
+ }
77
+
78
+ const flag = (v) => v === '1' || v === 1 || v === true;
79
+
80
+ /** Honeypot and contract-risk screen. Base: GoPlus + honeypot.is sell simulation. Robinhood Chain: GoPlus. Solana: GoPlus. */
81
+ export async function checkToken({ chain, address }) {
82
+ const c = CHAINS[chain];
83
+ const a = checkAddress(chain, address);
84
+ const out = { chain, address: a, verdict: 'unknown', reasons: [], cautions: [], sources: {} };
85
+ const jobs = [];
86
+ if (c.goplus) {
87
+ jobs.push(fetchJson(`${API.goplus}/token_security/${c.goplus}?contract_addresses=${a}`).then((j) => {
88
+ const r = j?.result?.[a.toLowerCase()];
89
+ if (!r) { out.sources.goplus = { error: 'no data for this token' }; return; }
90
+ out.sources.goplus = pick(r, ['token_name', 'token_symbol', 'is_honeypot', 'cannot_sell_all', 'buy_tax', 'sell_tax', 'is_mintable', 'owner_change_balance', 'hidden_owner', 'can_take_back_ownership', 'is_blacklisted', 'transfer_pausable', 'is_proxy', 'is_open_source', 'holder_count']);
91
+ if (flag(r.is_honeypot)) out.reasons.push('GoPlus flags it as a honeypot');
92
+ if (flag(r.cannot_sell_all)) out.reasons.push('holders cannot sell their full balance');
93
+ if (Number(r.sell_tax) >= 0.1) out.reasons.push(`sell tax ${(Number(r.sell_tax) * 100).toFixed(1)}%`);
94
+ if (flag(r.owner_change_balance)) out.reasons.push('owner can change balances');
95
+ if (flag(r.hidden_owner)) out.cautions.push('hidden owner');
96
+ if (flag(r.transfer_pausable)) out.cautions.push('transfers can be paused');
97
+ if (r.is_open_source === '0') out.cautions.push('contract source is not verified');
98
+ }).catch((e) => { out.sources.goplus = { error: e.message }; }));
99
+ }
100
+ if (chain === 'sol') {
101
+ jobs.push(fetchJson(`${API.goplus}/solana/token_security?contract_addresses=${a}`).then((j) => {
102
+ const r = j?.result?.[a];
103
+ if (!r) { out.sources.goplus = { error: 'no data for this token' }; return; }
104
+ const auth = (k) => r[k]?.status === '1';
105
+ out.sources.goplus = { mintable: auth('mintable'), freezable: auth('freezable'), closable: auth('closable'), balance_mutable_authority: auth('balance_mutable_authority'), non_transferable: r.non_transferable === '1', holder_count: r.holder_count };
106
+ if (auth('mintable')) out.cautions.push('mint authority is still active');
107
+ if (auth('freezable')) out.cautions.push('freeze authority is still active');
108
+ if (auth('balance_mutable_authority')) out.reasons.push('an authority can change balances');
109
+ if (r.non_transferable === '1') out.reasons.push('token is non-transferable');
110
+ }).catch((e) => { out.sources.goplus = { error: e.message }; }));
111
+ }
112
+ if (c.honeypotIs) {
113
+ jobs.push(fetchJson(`${API.honeypot}/IsHoneypot?address=${a}&chainID=${c.honeypotIs}`).then((j) => {
114
+ out.sources.honeypot_is = { simulationSuccess: j?.simulationSuccess, isHoneypot: j?.honeypotResult?.isHoneypot, buyTax: j?.simulationResult?.buyTax, sellTax: j?.simulationResult?.sellTax, risk: j?.summary?.risk };
115
+ if (j?.honeypotResult?.isHoneypot) out.reasons.push('honeypot.is sell simulation failed');
116
+ }).catch((e) => { out.sources.honeypot_is = { error: e.message }; }));
117
+ }
118
+ if (!jobs.length) {
119
+ out.note = `No public screening API covers ${c.name} yet. Open the token in the Wren app (https://wrenagent.app) for its bytecode check and sell-path simulation.`;
120
+ return out;
121
+ }
122
+ await Promise.all(jobs);
123
+ const answered = Object.values(out.sources).some((s) => !s.error);
124
+ out.verdict = out.reasons.length ? 'risky' : !answered ? 'unknown' : out.cautions.length ? 'caution' : 'no_flags';
125
+ out.disclaimer = 'Automated screen only. "no_flags" is not a guarantee and nothing here is financial advice.';
126
+ return out;
127
+ }
package/src/server.js ADDED
@@ -0,0 +1,63 @@
1
+ // The MCP server: market tools (no key) and account tools (memory, vault, agents; need an API key).
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { z } from 'zod';
4
+ import { VERSION, loadConfig } from './config.js';
5
+ import { CHAIN_IDS, getToken, newestTokens, checkToken } from './market.js';
6
+ import { accountClient } from './api.js';
7
+
8
+ const chain = z.enum(CHAIN_IDS).describe('Chain: ely = Elysium, base = Base, rh = Robinhood Chain, sol = Solana, hyp = HyperEVM');
9
+ const address = z.string().min(1).describe('Token contract address (0x…) or Solana mint');
10
+ const READ = { readOnlyHint: true, openWorldHint: true };
11
+ const WRITE = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
12
+
13
+ const ok = (data) => ({ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] });
14
+ const fail = (e) => ({ isError: true, content: [{ type: 'text', text: e?.message || String(e) }] });
15
+ const wrap = (fn) => async (args) => { try { return ok(await fn(args)); } catch (e) { return fail(e); } };
16
+
17
+ export function createServer({ env = process.env } = {}) {
18
+ const cfg = loadConfig(env);
19
+ const acct = accountClient(cfg);
20
+ const server = new McpServer({ name: 'wren', version: VERSION }, {
21
+ instructions: 'Wren gives live onchain market data for Elysium, Base, Robinhood Chain, Solana and HyperEVM, a honeypot screen, and the user\'s Wren memory, vault and agents. Run check_token before suggesting anyone buy a token. None of these tools can sign, send, swap or move funds. Nothing returned is financial advice.',
22
+ });
23
+ const tool = (name, title, description, inputSchema, annotations, fn) => server.registerTool(name, { title, description, inputSchema, annotations }, wrap(fn));
24
+
25
+ // ---- market (no key) ----
26
+ tool('get_token', 'Token market data', 'Live price, market cap, liquidity, volume and top pools for one token, from GeckoTerminal, DexScreener and (on Elysium) Montra.', { chain, address }, READ, getToken);
27
+ tool('newest_tokens', 'Newest tokens', 'The newest pools or launches on a chain (GeckoTerminal new pools; Montra launches on Elysium).', { chain, limit: z.number().int().min(1).max(50).optional().describe('How many, 1-50 (default 20)') }, READ, newestTokens);
28
+ tool('check_token', 'Honeypot check', 'Screen a token for honeypot and contract risks before buying: GoPlus and a honeypot.is sell simulation on Base, GoPlus on Robinhood Chain and Solana. Returns a verdict: risky (honeypot-level problems, in reasons), caution (powers the deployer still holds, in cautions), no_flags or unknown.', { chain, address }, READ, checkToken);
29
+
30
+ // ---- account (API key) ----
31
+ tool('whoami', 'Wren account', 'Show which Wren account this MCP is signed in as.', {}, { readOnlyHint: true }, () => acct.me());
32
+ tool('memory_add', 'Save a memory', 'Save a fact to the user\'s Wren memory. It shows up on the Memory page and in the Wren AI terminal.', {
33
+ text: z.string().min(1).max(4000).describe('The fact to remember, in one or two sentences'),
34
+ tags: z.array(z.string().max(40)).max(12).optional().describe('Optional lowercase tags'),
35
+ }, WRITE, acct.memoryAdd);
36
+ tool('memory_search', 'Search memory', 'Search the user\'s saved memories by words or tag. With no query it lists the newest.', {
37
+ query: z.string().max(200).optional(), tag: z.string().max(40).optional(), limit: z.number().int().min(1).max(100).optional(),
38
+ }, { readOnlyHint: true }, acct.memorySearch);
39
+ tool('memory_delete', 'Delete a memory', 'Delete one memory by id.', { id: z.string().min(1) }, { readOnlyHint: false, destructiveHint: true }, acct.memoryDelete);
40
+ tool('vault_list', 'List vault documents', 'List documents in the user\'s Wren vault, newest first. Optional title search.', {
41
+ query: z.string().max(200).optional(), limit: z.number().int().min(1).max(100).optional(),
42
+ }, { readOnlyHint: true }, acct.vaultList);
43
+ tool('vault_get', 'Read a vault document', 'Read the current version of a vault document.', { id: z.string().min(1) }, { readOnlyHint: true }, acct.vaultGet);
44
+ tool('vault_save', 'Save to the vault', 'Create a vault document, or with id save a new version of an existing one. Every version is kept.', {
45
+ id: z.string().optional().describe('Existing document id; leave out to create a new document'),
46
+ title: z.string().min(1).max(200).optional(), content: z.string().max(1_000_000).optional(),
47
+ note: z.string().max(300).optional().describe('Short note for this version'),
48
+ }, WRITE, ({ id, title, content, note }) => {
49
+ if (id) return acct.vaultUpdate({ id, title, content, note });
50
+ if (!title) throw new Error('title is required to create a document');
51
+ return acct.vaultCreate({ title, content: content ?? '' });
52
+ });
53
+ tool('vault_versions', 'Vault version history', 'List every saved version of a vault document.', { id: z.string().min(1) }, { readOnlyHint: true }, acct.vaultVersions);
54
+ tool('agent_list', 'List agents', 'List the user\'s Wren agents with their goal, status and schedule.', {}, { readOnlyHint: true }, () => acct.agentList());
55
+ tool('agent_create', 'Create an agent', 'Create a Wren agent record with a goal. Agents are records and notes; they cannot move funds.', {
56
+ name: z.string().min(1).max(100), goal: z.string().max(4000).optional(), schedule: z.string().max(100).optional().describe('Free-form schedule, e.g. "every 4h"'),
57
+ }, WRITE, acct.agentCreate);
58
+ tool('agent_note', 'Add an agent note', 'Add a note, learning or run log to an agent.', {
59
+ id: z.string().min(1), text: z.string().min(1).max(4000), kind: z.enum(['note', 'learning', 'run']).optional(),
60
+ }, WRITE, acct.agentNote);
61
+ tool('agent_notes', 'Read agent notes', 'Read an agent\'s notes, newest first.', { id: z.string().min(1) }, { readOnlyHint: true }, acct.agentNotes);
62
+ return server;
63
+ }