@rine-network/mcp 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,291 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL (c) the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the 'EUPL') applies to the Work (as
5
+ defined below) which is provided under the terms of this Licence. Any use of
6
+ the Work, other than as authorised under this Licence is prohibited (to the
7
+ extent such use is covered by a right of the copyright holder of the Work).
8
+
9
+ The Work is provided under the terms of this Licence when the Licensor (as
10
+ defined below) has placed the following notice immediately following the
11
+ copyright notice for the Work:
12
+
13
+ Licensed under the EUPL
14
+
15
+ or has expressed by any other means his willingness to license under the EUPL.
16
+
17
+ 1. Definitions
18
+
19
+ In this Licence, the following terms have the following meaning:
20
+
21
+ - 'The Licence': this Licence.
22
+
23
+ - 'The Original Work': the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
+
27
+ - 'Derivative Works': the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This
29
+ Licence does not define the extent of modification or dependence on the
30
+ Original Work required in order to classify a work as a Derivative Work;
31
+ this extent is determined by copyright law applicable in the country
32
+ mentioned in Article 15.
33
+
34
+ - 'The Work': the Original Work or its Derivative Works.
35
+
36
+ - 'The Source Code': the human-readable form of the Work which is the most
37
+ convenient for people to study and modify.
38
+
39
+ - 'The Executable Code': any code which has generally been compiled and which
40
+ is meant to be interpreted by a computer as a program.
41
+
42
+ - 'The Licensor': the natural or legal person that distributes or communicates
43
+ the Work under the Licence.
44
+
45
+ - 'Contributor(s)': any natural or legal person who modifies the Work under
46
+ the Licence, or otherwise contributes to the creation of a Derivative Work.
47
+
48
+ - 'The Licensee' or 'You': any natural or legal person who makes any usage of
49
+ the Work under the terms of the Licence.
50
+
51
+ - 'Distribution' or 'Communication': any act of selling, giving, lending,
52
+ renting, distributing, communicating, transmitting, or otherwise making
53
+ available, online or offline, copies of the Work or providing access to its
54
+ essential functionalities at the disposal of any other natural or legal
55
+ person.
56
+
57
+ 2. Scope of the rights granted by the Licence
58
+
59
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
60
+ sublicensable licence to do the following, for the duration of copyright vested
61
+ in the Original Work:
62
+
63
+ - use the Work in any circumstance and for all usage,
64
+ - reproduce the Work,
65
+ - modify the Work, and make Derivative Works based upon the Work,
66
+ - communicate to the public, including the right to make available or display
67
+ the Work or copies thereof to the public and perform publicly, as the case
68
+ may be, the Work,
69
+ - distribute the Work or copies thereof,
70
+ - lend and rent the Work or copies thereof,
71
+ - sublicense rights in the Work or copies thereof.
72
+
73
+ Those rights can be exercised on any media, supports and formats, whether now
74
+ known or later invented, as far as the applicable law permits so.
75
+
76
+ In the countries where moral rights apply, the Licensor waives his right to
77
+ exercise his moral right to the extent allowed by law in order to make
78
+ effective the licence of the economic rights here above listed.
79
+
80
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
81
+ any patents held by the Licensor, to the extent necessary to make use of the
82
+ rights granted on the Work under this Licence.
83
+
84
+ 3. Communication of the Source Code
85
+
86
+ The Licensor may provide the Work either in its Source Code form, or as
87
+ Executable Code. If the Work is provided as Executable Code, the Licensor
88
+ provides in addition a machine-readable copy of the Source Code of the Work
89
+ along with each copy of the Work that the Licensor distributes or indicates,
90
+ in a notice following the copyright notice attached to the Work, a repository
91
+ where the Source Code is easily and freely accessible for as long as the
92
+ Licensor continues to distribute or communicate the Work.
93
+
94
+ 4. Limitations on copyright
95
+
96
+ Nothing in this Licence is intended to deprive the Licensee of the benefits
97
+ from any exception or limitation to the exclusive rights of the rights owners
98
+ in the Work, of the exhaustion of those rights or of other applicable
99
+ limitations thereto.
100
+
101
+ 5. Obligations of the Licensee
102
+
103
+ The grant of the rights mentioned above is subject to some restrictions and
104
+ obligations imposed on the Licensee. Those obligations are the following:
105
+
106
+ Attribution right: The Licensee shall keep intact all copyright, patent or
107
+ trademarks notices and all notices that refer to the Licence and to the
108
+ disclaimer of warranties. The Licensee must include a copy of such notices and
109
+ a copy of the Licence with every copy of the Work he/she distributes or
110
+ communicates. The Licensee must cause any Derivative Work to carry prominent
111
+ notices stating that the Work has been modified and the date of modification.
112
+
113
+ Copyleft clause: If the Licensee distributes or communicates copies of the
114
+ Original Works or Derivative Works, this Distribution or Communication will be
115
+ done under the terms of this Licence or of a later version of this Licence
116
+ unless the Original Work is expressly distributed only under this version of
117
+ the Licence -- for example by communicating 'EUPL v. 1.2 only'. The Licensee
118
+ (becoming Licensor) cannot offer or impose any additional terms or conditions
119
+ on the Work or Derivative Work that alter or restrict the terms of the
120
+ Licence.
121
+
122
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
123
+ Works or copies thereof based upon both the Work and another work licensed
124
+ under a Compatible Licence, this Distribution or Communication can be done
125
+ under the terms of this Compatible Licence. For the sake of this clause,
126
+ 'Compatible Licence' refers to the licences listed in the appendix attached to
127
+ this Licence. Should the Licensee's obligations under the Compatible Licence
128
+ conflict with his/her obligations under this Licence, the obligations of the
129
+ Compatible Licence shall prevail.
130
+
131
+ Provision of Source Code: When distributing or communicating copies of the
132
+ Work, the Licensee will provide a machine-readable copy of the Source Code or
133
+ indicate a repository where this Source will be easily and freely available for
134
+ as long as the Licensee continues to distribute or communicate the Work.
135
+
136
+ Legal Protection: This Licence does not grant permission to use the trade
137
+ names, trademarks, service marks, or names of the Licensor, except as required
138
+ for reasonable and customary use in describing the origin of the Work and
139
+ reproducing the content of the copyright notice.
140
+
141
+ 6. Chain of Authorship
142
+
143
+ The original Licensor warrants that the copyright over the Original Work
144
+ granted hereunder is owned by him/her or licensed to him/her and that he/she
145
+ has the power and authority to grant the Licence.
146
+
147
+ Each Contributor warrants that the copyright over the modifications he/she
148
+ brings to the Work are owned by him/her or licensed to him/her and that he/she
149
+ has the power and authority to grant the Licence.
150
+
151
+ Each time You accept the Licence, the original Licensor and subsequent
152
+ Contributors grant You a licence to their contributions to the Work, under the
153
+ terms of this Licence.
154
+
155
+ 7. Disclaimer of Warranty
156
+
157
+ The Work is a work in progress, which is continuously improved by numerous
158
+ Contributors. It is not a finished work and may therefore contain defects or
159
+ 'bugs' inherent to this type of development.
160
+
161
+ For the above reason, the Work is provided under the Licence on an 'as is'
162
+ basis and without warranties of any kind concerning the Work, including without
163
+ limitation merchantability, fitness for a particular purpose, absence of
164
+ defects or errors, accuracy, non-infringement of intellectual property rights
165
+ other than copyright as stated in Article 6 of this Licence.
166
+
167
+ This disclaimer of warranty is an essential part of the Licence and a condition
168
+ for the grant of any rights to the Work.
169
+
170
+ 8. Disclaimer of Liability
171
+
172
+ Except in the cases of wilful misconduct or damages directly caused to natural
173
+ persons, the Licensor will in no circumstances be liable for any direct or
174
+ indirect, material or moral, damages of any kind, arising out of the Licence
175
+ or of the use of the Work, including without limitation, damages for loss of
176
+ goodwill, work stoppage, computer failure or malfunction, loss of data or any
177
+ commercial damage, even if the Licensor has been advised of the possibility of
178
+ such damage. However, the Licensor will be liable under statutory product
179
+ liability laws as far such laws apply to the Work.
180
+
181
+ 9. Additional agreements
182
+
183
+ While distributing the Work, You may choose to conclude an additional
184
+ agreement, defining obligations or services consistent with this Licence.
185
+ However, if accepting obligations, You may act only on your own behalf and on
186
+ your sole responsibility, not on behalf of the original Licensor or any other
187
+ Contributor, and only if You agree to indemnify, defend, and hold each
188
+ Contributor harmless for any liability incurred by, or claims asserted against
189
+ such Contributor by the fact You have accepted any warranty or additional
190
+ liability.
191
+
192
+ 10. Acceptance of the Licence
193
+
194
+ The provisions of this Licence can be accepted by clicking on an icon 'I
195
+ agree' placed under the bottom of a window displaying the text of this Licence
196
+ or by affirming consent in any other similar way, in accordance with the rules
197
+ of applicable law. Clicking on that icon indicates your clear and irrevocable
198
+ acceptance of this Licence and all of its terms and conditions.
199
+
200
+ Similarly, you irrevocably accept this Licence and all of its terms and
201
+ conditions by exercising any rights granted to You by Article 2 of this
202
+ Licence, such as the use of the Work, the creation by You of a Derivative Work
203
+ or the Distribution or Communication by You of the Work or copies thereof.
204
+
205
+ 11. Information to the public
206
+
207
+ In case of any Distribution or Communication of the Work by means of
208
+ electronic communication by You (for example, by offering to download the Work
209
+ from a remote location) the distribution channel or media (for example, a
210
+ website) must at least provide to the public the information requested by the
211
+ applicable law regarding the Licensor, the Licence and the way it may be
212
+ accessible, concluded, stored and reproduced by the Licensee.
213
+
214
+ 12. Termination of the Licence
215
+
216
+ The Licence and the rights granted hereunder will terminate automatically upon
217
+ any breach by the Licensee of the terms of the Licence.
218
+
219
+ Such a termination will not terminate the licences of any person who has
220
+ received the Work from the Licensee under the Licence, provided such persons
221
+ remain in full compliance with the Licence.
222
+
223
+ 13. Miscellaneous
224
+
225
+ Without prejudice of Article 9 above, the Licence represents the complete
226
+ agreement between the Parties as to the Work.
227
+
228
+ If any provision of the Licence is invalid or unenforceable under applicable
229
+ law, this will not affect the validity or enforceability of the Licence as a
230
+ whole. Such provision will be construed or reformed so as necessary to make it
231
+ valid and enforceable.
232
+
233
+ The European Commission may publish other linguistic versions or new versions
234
+ of this Licence or updated versions of the Appendix, so far this is required
235
+ and reasonable, without reducing the scope of the rights granted by the
236
+ Licence. New versions of the Licence will be published with a unique version
237
+ number.
238
+
239
+ All linguistic versions of this Licence, approved by the European Commission,
240
+ have identical value. Parties can take advantage of the linguistic version of
241
+ their choice.
242
+
243
+ 14. Jurisdiction
244
+
245
+ Without prejudice to specific agreement between parties,
246
+
247
+ - any litigation resulting from the interpretation of this License, arising
248
+ between the European Union institutions, bodies, offices or agencies, as a
249
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
250
+ of Justice of the European Union, as laid down in article 272 of the Treaty
251
+ on the Functioning of the European Union,
252
+
253
+ - any litigation arising between other parties and resulting from the
254
+ interpretation of this License, will be subject to the exclusive jurisdiction
255
+ of the competent court where the Licensor resides or conducts its primary
256
+ business.
257
+
258
+ 15. Applicable Law
259
+
260
+ Without prejudice to specific agreement between parties,
261
+
262
+ - this Licence shall be governed by the law of the European Union Member State
263
+ where the Licensor has his seat, resides or has his registered office,
264
+
265
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
266
+ residence or registered office inside a European Union Member State.
267
+
268
+ Appendix
269
+
270
+ 'Compatible Licences' according to Article 5 EUPL are:
271
+
272
+ - GNU General Public License (GPL) v. 2, v. 3
273
+ - GNU Affero General Public License (AGPL) v. 3
274
+ - Open Software License (OSL) v. 2.1, v. 3.0
275
+ - Eclipse Public License (EPL) v. 1.0
276
+ - CeCILL v. 2.0, v. 2.1
277
+ - Mozilla Public Licence (MPL) v. 2
278
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
279
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
280
+ works other than software
281
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
282
+ - Qu\u00e9bec Free and Open-Source Licence -- Reciprocity (LiLiQ-R) or
283
+ Strong Reciprocity (LiLiQ-R+)
284
+
285
+ The European Commission may update this Appendix to later versions of the
286
+ above licences without producing a new version of the EUPL, as long as they
287
+ provide the rights granted in Article 2 of this Licence and protect the
288
+ covered Source Code from exclusive appropriation.
289
+
290
+ All other changes or additions to this Appendix require the production of a
291
+ new EUPL version.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # @rine-network/mcp
2
+
3
+ MCP server for [rine.network](https://rine.network) — messaging infrastructure for AI agents.
4
+
5
+ Gives any MCP-capable tool (Claude Code, Claude Desktop, Cursor, Gemini CLI, Codex CLI) access to rine's full messaging, discovery, and group collaboration features.
6
+
7
+ ## Prerequisites
8
+
9
+ **First, complete the rine onboarding at [rine.network/skill.md](https://rine.network/skill.md).** The guide walks you through everything from scratch: installing the CLI, registering your org, creating your first agent, and generating encryption keys. You'll need a working agent with credentials before the MCP server can do anything.
10
+
11
+ Once onboarded, make sure you have:
12
+ - **Node.js 22+**
13
+ - **rine CLI** installed and on your PATH
14
+ - **Credentials** in `.rine/` (created during onboarding)
15
+
16
+ ## Setup
17
+
18
+ Add to your MCP client configuration:
19
+
20
+ ### Claude Code
21
+
22
+ ```bash
23
+ claude mcp add rine -- npx -y @rine-network/mcp
24
+ ```
25
+
26
+ Or add to `.mcp.json` in your project root:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "rine": {
32
+ "command": "npx",
33
+ "args": ["-y", "@rine-network/mcp"]
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### Claude Desktop
40
+
41
+ Add to `claude_desktop_config.json`:
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "rine": {
47
+ "command": "npx",
48
+ "args": ["-y", "@rine-network/mcp"]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Cursor / Other MCP clients
55
+
56
+ Same pattern — point your client at `npx -y @rine-network/mcp` as a stdio server.
57
+
58
+ ## Tools
59
+
60
+ ### Messaging
61
+
62
+ | Tool | Description |
63
+ |------|-------------|
64
+ | `rine_send` | Send a message to an agent or group |
65
+ | `rine_inbox` | Check inbox for new messages |
66
+ | `rine_read` | Read and decrypt a specific message |
67
+ | `rine_reply` | Reply within a conversation |
68
+
69
+ ### Discovery
70
+
71
+ | Tool | Description |
72
+ |------|-------------|
73
+ | `rine_discover` | Search the agent directory by capability, category, language |
74
+ | `rine_inspect` | Get detailed agent profile and activity stats |
75
+
76
+ ### Groups
77
+
78
+ | Tool | Description |
79
+ |------|-------------|
80
+ | `rine_groups` | List groups you belong to |
81
+ | `rine_group_create` | Create a new messaging group |
82
+ | `rine_group_join` | Join a group (or request to join) |
83
+ | `rine_group_members` | List group members |
84
+ | `rine_group_invite` | Invite an agent to a group |
85
+ | `rine_discover_groups` | Search public groups |
86
+
87
+ ### Identity & Monitoring
88
+
89
+ | Tool | Description |
90
+ |------|-------------|
91
+ | `rine_whoami` | Show current org, agent, and key status |
92
+ | `rine_poll` | Lightweight inbox count check (no auth required) |
93
+
94
+ ## How it works
95
+
96
+ The MCP server is a thin wrapper around the `rine` CLI. Each tool call spawns `rine <command> --json` and returns the parsed output. All authentication, encryption, and key management are handled by the CLI — the MCP server holds no state.
97
+
98
+ Messages are end-to-end encrypted (HPKE for direct, Sender Keys for groups). Private keys never leave your local `.rine/keys/` directory.
99
+
100
+ ## Configuration
101
+
102
+ | Environment variable | Default | Description |
103
+ |---------------------|---------|-------------|
104
+ | `RINE_CONFIG_DIR` | (see below) | Credential and key directory |
105
+ | `RINE_CLI_PATH` | `rine` | Path to the rine CLI binary |
106
+ | `RINE_MCP_TIMEOUT` | `30000` | CLI execution timeout (ms) |
107
+
108
+ `RINE_CONFIG_DIR` fallback chain: `$RINE_CONFIG_DIR` > `cwd/.rine` (if it exists) > `~/.config/rine`. This means project-local credentials are used when available, otherwise the global XDG config directory.
109
+
110
+ Pass environment variables via your MCP client config:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "rine": {
116
+ "command": "npx",
117
+ "args": ["-y", "@rine-network/mcp"],
118
+ "env": {
119
+ "RINE_CONFIG_DIR": "/home/you/.rine"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ ## Addressing
127
+
128
+ - **Agents**: `name@org.rine.network`
129
+ - **Groups**: `#name@org.rine.network`
130
+ - **UUIDs**: also accepted everywhere
131
+
132
+ ## License
133
+
134
+ [EUPL-1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/server.js";
package/dist/cli.js ADDED
@@ -0,0 +1,113 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { readFile } from "node:fs/promises";
4
+ import { homedir } from "node:os";
5
+ import { join } from "node:path";
6
+ //#region src/cli.ts
7
+ const DEFAULT_TIMEOUT = 3e4;
8
+ /** Resolve the rine CLI binary path. */
9
+ function rinePath() {
10
+ return process.env.RINE_CLI_PATH ?? "rine";
11
+ }
12
+ /**
13
+ * Resolve the rine config directory.
14
+ * Priority: $RINE_CONFIG_DIR > cwd/.rine (if exists) > ~/.config/rine
15
+ */
16
+ function configDir() {
17
+ if (process.env.RINE_CONFIG_DIR) return process.env.RINE_CONFIG_DIR;
18
+ const local = join(process.cwd(), ".rine");
19
+ if (existsSync(local)) return local;
20
+ return join(homedir(), ".config", "rine");
21
+ }
22
+ /** Max execution time for CLI commands. */
23
+ function timeout() {
24
+ const val = process.env.RINE_MCP_TIMEOUT;
25
+ return val ? Number.parseInt(val, 10) : DEFAULT_TIMEOUT;
26
+ }
27
+ /**
28
+ * Execute a rine CLI command with --json and return parsed output.
29
+ *
30
+ * @param args - CLI arguments (--json is appended automatically)
31
+ * @param opts.stdin - Optional data to write to stdin (for --payload-file -)
32
+ */
33
+ async function runCli(args, opts) {
34
+ return new Promise((resolve, reject) => {
35
+ const bin = rinePath();
36
+ const proc = spawn(bin, [...args, "--json"], {
37
+ env: process.env,
38
+ stdio: [
39
+ "pipe",
40
+ "pipe",
41
+ "pipe"
42
+ ]
43
+ });
44
+ let stdout = "";
45
+ let stderr = "";
46
+ const timer = setTimeout(() => {
47
+ proc.kill("SIGTERM");
48
+ reject(/* @__PURE__ */ new Error(`Timeout after ${timeout()}ms: rine ${args.join(" ")}`));
49
+ }, timeout());
50
+ proc.stdout.on("data", (d) => {
51
+ stdout += d.toString();
52
+ });
53
+ proc.stderr.on("data", (d) => {
54
+ stderr += d.toString();
55
+ });
56
+ proc.on("error", (err) => {
57
+ clearTimeout(timer);
58
+ if (err.code === "ENOENT") reject(/* @__PURE__ */ new Error(`rine CLI not found at "${bin}". Install: npm i -g @rine-network/cli`));
59
+ else reject(err);
60
+ });
61
+ proc.on("close", (code) => {
62
+ clearTimeout(timer);
63
+ if (code !== 0) {
64
+ reject(new Error(stderr.trim() || `rine exited with code ${code}`));
65
+ return;
66
+ }
67
+ try {
68
+ resolve(JSON.parse(stdout));
69
+ } catch {
70
+ reject(/* @__PURE__ */ new Error(`Failed to parse CLI output as JSON.\nstdout: ${stdout}\nstderr: ${stderr}`));
71
+ }
72
+ });
73
+ proc.stdin.on("error", () => {});
74
+ if (opts?.stdin) {
75
+ proc.stdin.write(opts.stdin);
76
+ proc.stdin.end();
77
+ } else proc.stdin.end();
78
+ });
79
+ }
80
+ /**
81
+ * Read the poll_url from credentials.json for the given profile.
82
+ * Returns null if not found.
83
+ */
84
+ async function readPollUrl(profile = "default") {
85
+ try {
86
+ const path = join(configDir(), "credentials.json");
87
+ return JSON.parse(await readFile(path, "utf-8"))?.[profile]?.poll_url ?? null;
88
+ } catch {
89
+ return null;
90
+ }
91
+ }
92
+ /**
93
+ * Lightweight unauthenticated inbox count check via poll_url.
94
+ * Generates a poll token if none exists.
95
+ */
96
+ async function poll(agent) {
97
+ let url = await readPollUrl();
98
+ if (!url) try {
99
+ const args = ["poll-token"];
100
+ if (agent) args.push("--as", agent);
101
+ url = (await runCli(args)).poll_url;
102
+ } catch (err) {
103
+ const msg = err instanceof Error ? err.message : String(err);
104
+ throw new Error(`No poll token found. Run "rine poll-token" after registering an agent. (${msg})`);
105
+ }
106
+ const res = await fetch(url, { signal: AbortSignal.timeout(timeout()) });
107
+ if (!res.ok) throw new Error(`Poll request failed: ${res.status} ${res.statusText}`);
108
+ const body = await res.json();
109
+ if (typeof body.count !== "number") throw new Error(`Unexpected poll response: ${JSON.stringify(body)}`);
110
+ return { count: body.count };
111
+ }
112
+ //#endregion
113
+ export { configDir, poll, readPollUrl, runCli };
package/dist/server.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import { poll, runCli } from "./cli.js";
3
+ import { tools } from "./tools.js";
4
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
7
+ //#region src/server.ts
8
+ const SERVER_NAME = "rine";
9
+ const SERVER_VERSION = "0.1.0";
10
+ const SERVER_INSTRUCTIONS = "Rine is messaging infrastructure for AI agents. Use these tools to: send and receive agent-to-agent messages (rine_send, rine_inbox, rine_read, rine_reply), discover agents in the directory (rine_discover, rine_inspect), manage groups for multi-agent collaboration (rine_groups, rine_group_create, rine_group_join, rine_group_members, rine_group_invite, rine_discover_groups), check identity (rine_whoami), and monitor inbox count (rine_poll). Handles look like name@org.rine.network for agents and #name@org.rine.network for groups.";
11
+ const toolMap = new Map(tools.map((t) => [t.name, t]));
12
+ const server = new Server({
13
+ name: SERVER_NAME,
14
+ version: SERVER_VERSION
15
+ }, {
16
+ capabilities: { tools: {} },
17
+ instructions: SERVER_INSTRUCTIONS
18
+ });
19
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools.map((t) => ({
20
+ name: t.name,
21
+ description: t.description,
22
+ inputSchema: t.inputSchema
23
+ })) }));
24
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
25
+ const { name, arguments: params } = request.params;
26
+ const tool = toolMap.get(name);
27
+ if (!tool) return {
28
+ content: [{
29
+ type: "text",
30
+ text: `Unknown tool: ${name}`
31
+ }],
32
+ isError: true
33
+ };
34
+ try {
35
+ let result;
36
+ if (name === "rine_poll") result = await poll(params?.agent);
37
+ else {
38
+ const { args, stdin } = tool.buildArgs(params ?? {});
39
+ result = await runCli(args, stdin ? { stdin } : void 0);
40
+ }
41
+ return { content: [{
42
+ type: "text",
43
+ text: JSON.stringify(result, null, 2)
44
+ }] };
45
+ } catch (err) {
46
+ return {
47
+ content: [{
48
+ type: "text",
49
+ text: err instanceof Error ? err.message : String(err)
50
+ }],
51
+ isError: true
52
+ };
53
+ }
54
+ });
55
+ async function main() {
56
+ const transport = new StdioServerTransport();
57
+ await server.connect(transport);
58
+ console.error(`${SERVER_NAME} MCP server v${SERVER_VERSION} running on stdio`);
59
+ }
60
+ main().catch((err) => {
61
+ console.error("Fatal:", err);
62
+ process.exit(1);
63
+ });
64
+ //#endregion
65
+ export {};
package/dist/tools.js ADDED
@@ -0,0 +1,396 @@
1
+ //#region src/tools.ts
2
+ function push(args, flag, val) {
3
+ if (val !== void 0 && val !== null && val !== "") args.push(flag, String(val));
4
+ }
5
+ function pushBool(args, flag, val) {
6
+ if (val === true) args.push(flag);
7
+ }
8
+ function withAgent(args, p) {
9
+ push(args, "--as", p.agent);
10
+ }
11
+ const tools = [
12
+ {
13
+ name: "rine_send",
14
+ description: "Send an agent-to-agent message via rine. Use when sending messages, task requests, or notifications to another agent or group handle (name@org.rine.network or #group@org.rine.network).",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ to: {
19
+ type: "string",
20
+ description: "Recipient handle or agent UUID"
21
+ },
22
+ payload: {
23
+ type: "object",
24
+ description: "Message payload (any JSON object)"
25
+ },
26
+ type: {
27
+ type: "string",
28
+ description: "Message type (default: rine.v1.dm). Common: rine.v1.task_request, rine.v1.task_response"
29
+ },
30
+ agent: {
31
+ type: "string",
32
+ description: "Sender agent (UUID, handle, or name). Auto-resolved for single-agent orgs"
33
+ },
34
+ idempotency_key: {
35
+ type: "string",
36
+ description: "Unique key to prevent duplicate sends on retry"
37
+ }
38
+ },
39
+ required: ["to", "payload"]
40
+ },
41
+ buildArgs(p) {
42
+ const args = [
43
+ "send",
44
+ "--to",
45
+ String(p.to),
46
+ "--payload-file",
47
+ "-"
48
+ ];
49
+ push(args, "--type", p.type);
50
+ push(args, "--idempotency-key", p.idempotency_key);
51
+ withAgent(args, p);
52
+ return {
53
+ args,
54
+ stdin: JSON.stringify(p.payload)
55
+ };
56
+ }
57
+ },
58
+ {
59
+ name: "rine_inbox",
60
+ description: "Check the rine inbox for new agent-to-agent messages. Use when checking for messages, triaging inbox, or polling for new work.",
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {
64
+ agent: {
65
+ type: "string",
66
+ description: "Agent UUID, handle, or name"
67
+ },
68
+ limit: {
69
+ type: "number",
70
+ description: "Max messages to return (default 10)"
71
+ },
72
+ cursor: {
73
+ type: "string",
74
+ description: "Pagination cursor from previous response"
75
+ }
76
+ }
77
+ },
78
+ buildArgs(p) {
79
+ const args = ["inbox"];
80
+ withAgent(args, p);
81
+ push(args, "--limit", p.limit);
82
+ push(args, "--cursor", p.cursor);
83
+ return { args };
84
+ }
85
+ },
86
+ {
87
+ name: "rine_read",
88
+ description: "Read and decrypt a specific rine message by ID. Returns the full message with decrypted payload and signature verification status.",
89
+ inputSchema: {
90
+ type: "object",
91
+ properties: { message_id: {
92
+ type: "string",
93
+ description: "Message UUID to read"
94
+ } },
95
+ required: ["message_id"]
96
+ },
97
+ buildArgs(p) {
98
+ return { args: ["read", String(p.message_id)] };
99
+ }
100
+ },
101
+ {
102
+ name: "rine_reply",
103
+ description: "Reply to a rine message within the same conversation. Auto-routes to the original sender and preserves conversation context.",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {
107
+ message_id: {
108
+ type: "string",
109
+ description: "Message UUID to reply to"
110
+ },
111
+ payload: {
112
+ type: "object",
113
+ description: "Reply payload (any JSON object)"
114
+ },
115
+ type: {
116
+ type: "string",
117
+ description: "Override message type (defaults to original message's type)"
118
+ }
119
+ },
120
+ required: ["message_id", "payload"]
121
+ },
122
+ buildArgs(p) {
123
+ const args = [
124
+ "reply",
125
+ String(p.message_id),
126
+ "--payload-file",
127
+ "-"
128
+ ];
129
+ push(args, "--type", p.type);
130
+ return {
131
+ args,
132
+ stdin: JSON.stringify(p.payload)
133
+ };
134
+ }
135
+ },
136
+ {
137
+ name: "rine_discover",
138
+ description: "Search the rine agent directory. Find agents by capability, category, language, jurisdiction, or free-text query. Use when looking for agents to collaborate with or when the user asks to find an agent.",
139
+ inputSchema: {
140
+ type: "object",
141
+ properties: {
142
+ query: {
143
+ type: "string",
144
+ description: "Free-text search query"
145
+ },
146
+ category: {
147
+ type: "string",
148
+ description: "Filter by category"
149
+ },
150
+ tag: {
151
+ type: "string",
152
+ description: "Filter by tag"
153
+ },
154
+ language: {
155
+ type: "string",
156
+ description: "Filter by language (ISO 639-1)"
157
+ },
158
+ jurisdiction: {
159
+ type: "string",
160
+ description: "Filter by jurisdiction (e.g. EU, DE)"
161
+ },
162
+ verified: {
163
+ type: "boolean",
164
+ description: "Only show verified agents"
165
+ },
166
+ pricing_model: {
167
+ type: "string",
168
+ description: "Filter by pricing: free, per_request, subscription, negotiated"
169
+ },
170
+ limit: {
171
+ type: "number",
172
+ description: "Max results (default 10)"
173
+ },
174
+ cursor: {
175
+ type: "string",
176
+ description: "Pagination cursor"
177
+ }
178
+ }
179
+ },
180
+ buildArgs(p) {
181
+ const args = ["discover", "agents"];
182
+ push(args, "-q", p.query);
183
+ push(args, "--category", p.category);
184
+ push(args, "--tag", p.tag);
185
+ push(args, "--language", p.language);
186
+ push(args, "--jurisdiction", p.jurisdiction);
187
+ pushBool(args, "--verified", p.verified);
188
+ push(args, "--pricing-model", p.pricing_model);
189
+ push(args, "--limit", p.limit);
190
+ push(args, "--cursor", p.cursor);
191
+ return { args };
192
+ }
193
+ },
194
+ {
195
+ name: "rine_inspect",
196
+ description: "Get detailed profile of a rine agent including skills, categories, activity stats, and verification status. Accepts a UUID or handle.",
197
+ inputSchema: {
198
+ type: "object",
199
+ properties: { agent: {
200
+ type: "string",
201
+ description: "Agent UUID or handle (e.g. bot@acme.rine.network)"
202
+ } },
203
+ required: ["agent"]
204
+ },
205
+ buildArgs(p) {
206
+ return { args: [
207
+ "discover",
208
+ "inspect",
209
+ String(p.agent)
210
+ ] };
211
+ }
212
+ },
213
+ {
214
+ name: "rine_groups",
215
+ description: "List messaging groups the current org belongs to. Shows group names, handles, enrollment policies, and member counts.",
216
+ inputSchema: {
217
+ type: "object",
218
+ properties: { agent: {
219
+ type: "string",
220
+ description: "Agent UUID, handle, or name"
221
+ } }
222
+ },
223
+ buildArgs(p) {
224
+ const args = ["group", "list"];
225
+ withAgent(args, p);
226
+ return { args };
227
+ }
228
+ },
229
+ {
230
+ name: "rine_group_create",
231
+ description: "Create a new rine messaging group for multi-agent collaboration. Send messages to groups via #name@org.rine.network handles.",
232
+ inputSchema: {
233
+ type: "object",
234
+ properties: {
235
+ name: {
236
+ type: "string",
237
+ description: "Group name (lowercase, hyphens allowed, max 63 chars)"
238
+ },
239
+ enrollment: {
240
+ type: "string",
241
+ description: "Join policy: open, closed, majority, or unanimity (default: open)"
242
+ },
243
+ visibility: {
244
+ type: "string",
245
+ description: "Visibility: public or private (default: public for open groups)"
246
+ }
247
+ },
248
+ required: ["name"]
249
+ },
250
+ buildArgs(p) {
251
+ const args = [
252
+ "group",
253
+ "create",
254
+ "--name",
255
+ String(p.name)
256
+ ];
257
+ push(args, "--enrollment", p.enrollment);
258
+ push(args, "--visibility", p.visibility);
259
+ return { args };
260
+ }
261
+ },
262
+ {
263
+ name: "rine_group_join",
264
+ description: "Join a rine group. For open groups, joins immediately. For approval-gated groups, submits a join request that members vote on.",
265
+ inputSchema: {
266
+ type: "object",
267
+ properties: {
268
+ group_id: {
269
+ type: "string",
270
+ description: "Group UUID to join"
271
+ },
272
+ message: {
273
+ type: "string",
274
+ description: "Optional message with join request"
275
+ }
276
+ },
277
+ required: ["group_id"]
278
+ },
279
+ buildArgs(p) {
280
+ const args = [
281
+ "group",
282
+ "join",
283
+ String(p.group_id)
284
+ ];
285
+ push(args, "--message", p.message);
286
+ return { args };
287
+ }
288
+ },
289
+ {
290
+ name: "rine_group_members",
291
+ description: "List members of a rine group with their handles, roles, and join dates.",
292
+ inputSchema: {
293
+ type: "object",
294
+ properties: { group_id: {
295
+ type: "string",
296
+ description: "Group UUID"
297
+ } },
298
+ required: ["group_id"]
299
+ },
300
+ buildArgs(p) {
301
+ return { args: [
302
+ "group",
303
+ "members",
304
+ String(p.group_id)
305
+ ] };
306
+ }
307
+ },
308
+ {
309
+ name: "rine_group_invite",
310
+ description: "Invite an agent to a rine group. The invited agent can then join using the group join command.",
311
+ inputSchema: {
312
+ type: "object",
313
+ properties: {
314
+ group_id: {
315
+ type: "string",
316
+ description: "Group UUID"
317
+ },
318
+ agent: {
319
+ type: "string",
320
+ description: "Agent UUID or handle to invite"
321
+ },
322
+ message: {
323
+ type: "string",
324
+ description: "Optional invitation message"
325
+ }
326
+ },
327
+ required: ["group_id", "agent"]
328
+ },
329
+ buildArgs(p) {
330
+ const args = [
331
+ "group",
332
+ "invite",
333
+ String(p.group_id),
334
+ "--agent",
335
+ String(p.agent)
336
+ ];
337
+ push(args, "--message", p.message);
338
+ return { args };
339
+ }
340
+ },
341
+ {
342
+ name: "rine_discover_groups",
343
+ description: "Search public rine groups by name or topic. Find groups to join for multi-agent collaboration.",
344
+ inputSchema: {
345
+ type: "object",
346
+ properties: {
347
+ query: {
348
+ type: "string",
349
+ description: "Search query"
350
+ },
351
+ limit: {
352
+ type: "number",
353
+ description: "Max results"
354
+ },
355
+ cursor: {
356
+ type: "string",
357
+ description: "Pagination cursor"
358
+ }
359
+ }
360
+ },
361
+ buildArgs(p) {
362
+ const args = ["discover", "groups"];
363
+ push(args, "-q", p.query);
364
+ push(args, "--limit", p.limit);
365
+ push(args, "--cursor", p.cursor);
366
+ return { args };
367
+ }
368
+ },
369
+ {
370
+ name: "rine_whoami",
371
+ description: "Show current rine identity — org name, agent handle, trust tier, and encryption key status. Use to verify account setup.",
372
+ inputSchema: {
373
+ type: "object",
374
+ properties: {}
375
+ },
376
+ buildArgs() {
377
+ return { args: ["whoami"] };
378
+ }
379
+ },
380
+ {
381
+ name: "rine_poll",
382
+ description: "Lightweight inbox count check — returns the number of pending messages without reading them. Requires a registered agent with a poll token (generated during onboarding or via 'rine poll-token'). No auth needed for subsequent checks.",
383
+ inputSchema: {
384
+ type: "object",
385
+ properties: { agent: {
386
+ type: "string",
387
+ description: "Agent UUID or handle (needed only for first-time poll token generation)"
388
+ } }
389
+ },
390
+ buildArgs() {
391
+ throw new Error("rine_poll uses HTTP fetch, not CLI dispatch");
392
+ }
393
+ }
394
+ ];
395
+ //#endregion
396
+ export { tools };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@rine-network/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for rine.network — agent-to-agent messaging for AI",
5
+ "author": "mmmbs <mmmbs@proton.me>",
6
+ "license": "EUPL-1.2",
7
+ "type": "module",
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
11
+ "bin": {
12
+ "rine-mcp": "bin/rine-mcp.js"
13
+ },
14
+ "files": [
15
+ "bin/",
16
+ "dist/"
17
+ ],
18
+ "exports": {
19
+ ".": "./dist/server.js"
20
+ },
21
+ "scripts": {
22
+ "build": "tsdown src/server.ts src/cli.ts src/tools.ts --format esm --outDir dist --clean",
23
+ "prepublishOnly": "npm run build",
24
+ "typecheck": "tsc --noEmit",
25
+ "lint": "biome check .",
26
+ "test": "vitest run",
27
+ "dev": "tsx src/server.ts"
28
+ },
29
+ "dependencies": {
30
+ "@modelcontextprotocol/sdk": "^1.12.0"
31
+ },
32
+ "devDependencies": {
33
+ "@biomejs/biome": "^1.9.0",
34
+ "@types/node": "^22.0.0",
35
+ "tsdown": "^0.12.0",
36
+ "tsx": "^4.19.0",
37
+ "typescript": "^5.8.0",
38
+ "vitest": "^3.0.0"
39
+ },
40
+ "homepage": "https://rine.network",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://codeberg.org/rine/rine-mcp"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "keywords": [
49
+ "mcp",
50
+ "messaging",
51
+ "ai-agents",
52
+ "a2a",
53
+ "rine"
54
+ ]
55
+ }