@agenticmail/mcp 0.7.1 → 0.7.2
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/README.md +24 -6
- package/dist/index.js +71 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ When connected, your AI agent can send emails and texts, check inboxes, reply to
|
|
|
10
10
|
npm install -g @agenticmail/mcp
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Requirements:** Node.js
|
|
13
|
+
**Requirements:** Node.js 22+, AgenticMail API server running
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ Add to your MCP client configuration (e.g., `.mcp.json` or project settings):
|
|
|
35
35
|
"command": "npx",
|
|
36
36
|
"args": ["agenticmail-mcp"],
|
|
37
37
|
"env": {
|
|
38
|
-
"AGENTICMAIL_API_URL": "http://127.0.0.1:
|
|
38
|
+
"AGENTICMAIL_API_URL": "http://127.0.0.1:3829",
|
|
39
39
|
"AGENTICMAIL_API_KEY": "ak_your_agent_key"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -56,7 +56,7 @@ For desktop AI applications, add to your MCP configuration file. Example paths:
|
|
|
56
56
|
"command": "npx",
|
|
57
57
|
"args": ["agenticmail-mcp"],
|
|
58
58
|
"env": {
|
|
59
|
-
"AGENTICMAIL_API_URL": "http://127.0.0.1:
|
|
59
|
+
"AGENTICMAIL_API_URL": "http://127.0.0.1:3829",
|
|
60
60
|
"AGENTICMAIL_API_KEY": "ak_your_agent_key"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -68,9 +68,27 @@ For desktop AI applications, add to your MCP configuration file. Example paths:
|
|
|
68
68
|
|
|
69
69
|
| Variable | Required | Description |
|
|
70
70
|
|----------|----------|-------------|
|
|
71
|
-
| `AGENTICMAIL_API_URL` | Yes | AgenticMail API server URL (
|
|
72
|
-
| `AGENTICMAIL_API_KEY` | Yes | Agent API key (`ak_...`). Determines
|
|
73
|
-
| `AGENTICMAIL_MASTER_KEY` | No | Master key (`mk_...`). Required for admin operations (create/delete agents, approve emails, gateway config). |
|
|
71
|
+
| `AGENTICMAIL_API_URL` | Yes | AgenticMail API server URL. Default port is **`3829`** (changed from `3100` in `@agenticmail/mcp@0.7.x` to avoid common dev-tool conflicts). Example: `http://127.0.0.1:3829`. |
|
|
72
|
+
| `AGENTICMAIL_API_KEY` | Yes¹ | Agent API key (`ak_...`). Determines the default identity this MCP server acts as when a tool call doesn't pass `_account`. |
|
|
73
|
+
| `AGENTICMAIL_MASTER_KEY` | No | Master key (`mk_...`). Required for admin operations (create/delete agents, approve emails, gateway config). **Also enables on-demand `_account` resolution** — any tool call passing `_account: "<name>"` will lazily fetch that agent's API key via the master key the first time it sees the name, so freshly-`create_account`'d agents become addressable without restarting the MCP server. |
|
|
74
|
+
| `AGENTICMAIL_ACCOUNT_KEYS_JSON` | No | JSON map of `{"<agentName>": "<apiKey>"}` for per-call identity switching. When the caller passes `_account: "Fola"` (etc.), the server authenticates AS that agent for the duration of the call. Populated automatically by `agenticmail claudecode install` for the Claude Code integration. |
|
|
75
|
+
|
|
76
|
+
¹ Either `AGENTICMAIL_API_KEY` OR `AGENTICMAIL_MASTER_KEY` (or `AGENTICMAIL_ACCOUNT_KEYS_JSON`) must be set, but you don't strictly need all three.
|
|
77
|
+
|
|
78
|
+
### Per-call identity switching (`_account`)
|
|
79
|
+
|
|
80
|
+
Every tool's input schema accepts an optional `_account: "<name>"` parameter. When passed, the server resolves that name to an apiKey (from `AGENTICMAIL_ACCOUNT_KEYS_JSON`, then falling back to a live master-keyed lookup of `/accounts`) and runs the call as that agent. Without `_account`, the call uses `AGENTICMAIL_API_KEY` as the default identity.
|
|
81
|
+
|
|
82
|
+
This is what powers the [`@agenticmail/claudecode`](https://www.npmjs.com/package/@agenticmail/claudecode) integration: one MCP server process, many AgenticMail identities. A Claude Code subagent that "is" Fola passes `_account: "Fola"` on every call and ends up reading Fola's real inbox, sending mail from `fola@localhost`, and so on.
|
|
83
|
+
|
|
84
|
+
### Meta-tools for cheap discovery (`request_tools` + `invoke`)
|
|
85
|
+
|
|
86
|
+
To keep host context windows small, only ~10 of the 62 tools are pre-declared in a typical subagent's `tools:` whitelist. The other ~50 stay reachable through two always-on meta-tools:
|
|
87
|
+
|
|
88
|
+
- **`request_tools({ query?, sets? })`** — Returns a text catalogue of the unloaded tools, grouped by set (`mail_extras`, `mail_compose`, `sms`, `account_admin`, …). Optional substring filter or set-name filter.
|
|
89
|
+
- **`invoke({ tool, args, _account? })`** — Dispatches to any of the 62 tools by name. The agent uses `request_tools` to discover, `invoke` to call.
|
|
90
|
+
|
|
91
|
+
Token impact: a typical subagent spawn loads ~3K tokens of tool schemas instead of ~15K. The cost is one extra round trip for uncommon operations (discover → invoke), which is almost always a worthwhile trade.
|
|
74
92
|
|
|
75
93
|
---
|
|
76
94
|
|
package/dist/index.js
CHANGED
|
@@ -22878,7 +22878,7 @@ var toolDefinitions = [
|
|
|
22878
22878
|
},
|
|
22879
22879
|
{
|
|
22880
22880
|
name: "create_account",
|
|
22881
|
-
description:
|
|
22881
|
+
description: 'Create a new AgenticMail agent (email account + identity + API key + persona derived from role/metadata). Requires master API key. After creation: address them at `<name>@localhost`, delegate work via `call_agent({ target: "<name>", task: ... })`, or hand off via `send_email` / `message_agent`. The new agent acts as themselves \u2014 you never need to (and must not) roleplay them inside your host\'s native sub-agent tool.',
|
|
22882
22882
|
inputSchema: {
|
|
22883
22883
|
type: "object",
|
|
22884
22884
|
properties: {
|
|
@@ -22999,7 +22999,7 @@ var toolDefinitions = [
|
|
|
22999
22999
|
},
|
|
23000
23000
|
{
|
|
23001
23001
|
name: "list_agents",
|
|
23002
|
-
description: "List all AI agents in the system with their email addresses and roles. Use this to discover which agents you can
|
|
23002
|
+
description: "List all AI agents in the system with their email addresses and roles. Use this to discover which agents you can call via call_agent (sync RPC) or email via send_email / message_agent (async). DO NOT spawn one of your host's native sub-agents and roleplay AS these agents \u2014 each one is a real identity with its own mailbox; just address them through AgenticMail and let them work as themselves.",
|
|
23003
23003
|
inputSchema: {
|
|
23004
23004
|
type: "object",
|
|
23005
23005
|
properties: {}
|
|
@@ -23007,7 +23007,7 @@ var toolDefinitions = [
|
|
|
23007
23007
|
},
|
|
23008
23008
|
{
|
|
23009
23009
|
name: "message_agent",
|
|
23010
|
-
description: "
|
|
23010
|
+
description: "Async fire-and-forget: deliver a message to another AI agent's inbox. They will process it on their own schedule (immediately if a dispatcher is attached, later otherwise) and may reply by email. Use this for non-blocking handoffs. Prefer `call_agent` when you need a structured reply back. Both flows let the target agent do the work AS THEMSELVES \u2014 never roleplay them inside your own host.",
|
|
23011
23011
|
inputSchema: {
|
|
23012
23012
|
type: "object",
|
|
23013
23013
|
properties: {
|
|
@@ -23248,7 +23248,7 @@ var toolDefinitions = [
|
|
|
23248
23248
|
},
|
|
23249
23249
|
{
|
|
23250
23250
|
name: "call_agent",
|
|
23251
|
-
description:
|
|
23251
|
+
description: `Synchronous RPC to delegate work to another AgenticMail agent. Pipeline: the task is queued in AgenticMail, the target agent processes it AS THEMSELVES (under their real identity, mailbox, persona, and audit trail), and the structured result returns into your call. THIS IS HOW MULTI-AGENT COORDINATION IS SUPPOSED TO WORK from any MCP host. Do not, instead, spawn one of your host's native sub-agents and tell it to "act as <target>" \u2014 that produces output under your identity, never touches the target's inbox, and skips their persona. Times out after the specified duration (default 180s, max 300s).`,
|
|
23252
23252
|
inputSchema: {
|
|
23253
23253
|
type: "object",
|
|
23254
23254
|
properties: {
|
|
@@ -24902,12 +24902,74 @@ function jsonSchemaToZod(schema, topLevel = false) {
|
|
|
24902
24902
|
}
|
|
24903
24903
|
return schema.description ? result.describe(schema.description) : result;
|
|
24904
24904
|
}
|
|
24905
|
+
var SERVER_INSTRUCTIONS = [
|
|
24906
|
+
"\u{1F380} AgenticMail \u2014 multi-agent email + SMS infrastructure.",
|
|
24907
|
+
"",
|
|
24908
|
+
"AgenticMail agents are NOT prompts you wrap around your host's native",
|
|
24909
|
+
"sub-agent tool. Each AgenticMail agent is a persistent identity with its",
|
|
24910
|
+
"own inbox, API key, persona, and audit trail. Address other agents through",
|
|
24911
|
+
"AgenticMail's own primitives below \u2014 never roleplay them inside your host.",
|
|
24912
|
+
"",
|
|
24913
|
+
"How to coordinate work between agents \u2014 the right way:",
|
|
24914
|
+
"",
|
|
24915
|
+
"1. List or create the agents you need (`list_agents`, `create_account`).",
|
|
24916
|
+
"2. Send them work using ONE of:",
|
|
24917
|
+
" \u2022 `call_agent({ target, task, payload?, timeout? })` \u2014 SYNCHRONOUS RPC.",
|
|
24918
|
+
" Fires a structured task at the target agent and waits for their",
|
|
24919
|
+
" result. The target processes the task as themselves (under their",
|
|
24920
|
+
" own identity and mailbox) and the structured result returns into",
|
|
24921
|
+
" your call. Use this when you need an answer back.",
|
|
24922
|
+
' \u2022 `send_email({ to: "<name>@localhost", ... })` or',
|
|
24923
|
+
" `message_agent({ agent, subject, text })` \u2014 ASYNCHRONOUS.",
|
|
24924
|
+
" Mail lands in their inbox; they process it on their own schedule",
|
|
24925
|
+
" and may reply by email. Use this for fire-and-forget handoffs.",
|
|
24926
|
+
"3. Read replies with `list_inbox` + `read_email`, or `search_emails`.",
|
|
24927
|
+
"",
|
|
24928
|
+
"What NOT to do (regardless of host \u2014 Claude Code, ChatGPT, Cursor, Grok, \u2026):",
|
|
24929
|
+
"",
|
|
24930
|
+
"\u2717 Do NOT spawn a native sub-agent / sub-task / parallel-thinking tool of",
|
|
24931
|
+
' your host and instruct it to "act as Lyra" / "write as Orion". That',
|
|
24932
|
+
" produces output under YOUR identity, never reaches the named agent's",
|
|
24933
|
+
" inbox, and bypasses their persona, signatures, outbound guard, and",
|
|
24934
|
+
" audit trail. The real agent has not actually thought anything.",
|
|
24935
|
+
"\u2717 Do NOT compose an agent's reply yourself in the host session and then",
|
|
24936
|
+
" `send_email` it on their behalf. Let `call_agent` (or an email handoff)",
|
|
24937
|
+
" produce the reply from the real agent.",
|
|
24938
|
+
'\u2717 Do NOT pass `_account: "<other-agent>"` to act AS another agent. That',
|
|
24939
|
+
" falsifies the From: header. Use `call_agent` to delegate instead.",
|
|
24940
|
+
"",
|
|
24941
|
+
"How the wake-up actually happens (host-dependent \u2014 best-effort):",
|
|
24942
|
+
" - With the Claude Code integration installed, a dispatcher daemon",
|
|
24943
|
+
" auto-wakes the target agent as a Claude Code subagent when mail",
|
|
24944
|
+
" arrives or `call_agent` fires.",
|
|
24945
|
+
" - With other MCP hosts (no dispatcher), `send_email` / `message_agent`",
|
|
24946
|
+
" still deliver the mail; a human or another scheduled process picks",
|
|
24947
|
+
" it up later. `call_agent` will still queue the task and return its",
|
|
24948
|
+
" result once any worker (yourself, a cron, another agent) processes",
|
|
24949
|
+
" it \u2014 see `check_tasks` / `claim_task` / `submit_result`.",
|
|
24950
|
+
" Either way, the RIGHT primitives from your side are the same:",
|
|
24951
|
+
" call_agent / send_email / message_agent. Never roleplay.",
|
|
24952
|
+
"",
|
|
24953
|
+
"Identity & `_account`:",
|
|
24954
|
+
' Every tool call accepts an optional `_account: "<your-agent-name>"` to',
|
|
24955
|
+
" scope the call to a specific agent. From the HOST session, omit it to",
|
|
24956
|
+
" use bridge identity, or pass it to read/write a specific agent's",
|
|
24957
|
+
" mailbox directly. From inside an agent's own context, ALWAYS pass",
|
|
24958
|
+
' `_account: "<self>"`.',
|
|
24959
|
+
"",
|
|
24960
|
+
"Tool surface: ~62 tools across email, SMS, contacts, drafts, templates,",
|
|
24961
|
+
"rules, tags, search, scheduling, RPC. Only ~10 are pre-loaded; the rest",
|
|
24962
|
+
"are reachable via `request_tools` (discover) + `invoke` (call)."
|
|
24963
|
+
].join("\n");
|
|
24905
24964
|
function createMcpServer() {
|
|
24906
|
-
const server = new McpServer(
|
|
24907
|
-
|
|
24908
|
-
|
|
24909
|
-
|
|
24910
|
-
|
|
24965
|
+
const server = new McpServer(
|
|
24966
|
+
{
|
|
24967
|
+
name: "\u{1F380} AgenticMail",
|
|
24968
|
+
version: "0.2.29",
|
|
24969
|
+
description: "\u{1F380} AgenticMail \u2014 Email infrastructure for AI agents. By Ope Olatunji (https://github.com/agenticmail/agenticmail)"
|
|
24970
|
+
},
|
|
24971
|
+
{ instructions: SERVER_INSTRUCTIONS }
|
|
24972
|
+
);
|
|
24911
24973
|
const ACCOUNT_PROP = {
|
|
24912
24974
|
type: "string",
|
|
24913
24975
|
description: 'Optional. Override identity for THIS call: pass the AgenticMail agent name (e.g. "Fola") to authenticate as that agent. Requires AGENTICMAIL_ACCOUNT_KEYS_JSON to contain a matching key. Omit to use the default identity (AGENTICMAIL_API_KEY).'
|