Skip to main content
Glama
README.md
# Ashwire

Ashwire is a self-hosted MCP connection hub. This first build uses the [Arachne Discord MCP](https://github.com/SolanceLab/arachne-discord-mcp) codebase under its AGPL-3.0 license. It retains the Discord gateway, per-identity webhook name and avatar, OAuth for remote MCP clients, and server-admin approval of channel and tool access. Other services are a planned extension, not yet implemented.

## Get the pilot source

Run `git clone https://github.com/liladuz-maker/ashwire.git`, then `cd ashwire/cloudflare`, `npm ci`, and `npm run build`. See [copyright and upstream credits](NOTICE.md) and the [license](LICENSE).

## Cloudflare identity pilot

The new `cloudflare/` app is deployed at https://ashwire-pilot.keepsake-staging.workers.dev with its own D1 database. It serves the public landing page, an Ashwire bot invite, and a dashboard for Discord sign-in, identity creation, display-name editing, and image uploads. Each avatar is stored in D1 and served from an Ashwire URL. With `DISCORD_BOT_TOKEN` set as a Worker secret, server owners can grant an identity all channels the bot can access, including private channels, or limit it to selected channels. The all-channels grant follows later Discord permission changes. The dashboard shows when the bot lacks View Channel or Manage Webhooks. Saving access creates a mentionable Discord role named `{identity} · Ashwire` so it remains distinct from Arachne or other bots' roles. Owners can send test messages under each identity's name and image through Discord webhooks. Each identity has an OAuth-protected Streamable HTTP MCP URL with tools to inspect the identity, list accessible channels, read queued messages, and send a message. A single Durable Object connects the shared bot to Discord's Gateway once a server owner approves access. With Message Content Intent enabled in the Discord Developer Portal and `DISCORD_MESSAGE_CONTENT_INTENT=true` in the Worker, it queues messages from all approved channels the bot can view and marks entity role mentions as addressed. Without that setting, it queues direct Ashwire bot mentions only. Message content is encrypted per identity in D1 with AES-GCM using a key derived from the bot token; rotating the token makes pending messages unreadable. Messages expire after 15 minutes and each identity queue is capped at 500. An AI client must call the message tool to read them; Ashwire does not make ChatGPT respond autonomously. The inherited Node.js application below remains a local reference implementation, not the deployed backend.

## Run the inherited Node.js implementation

Requirements: Node.js 22 or 24, a Discord application with a bot, and a public HTTPS backend for ChatGPT's remote MCP connection.

1. Install with `npm ci` in this directory and `npm ci` in `dashboard/`.
2. Copy `.env.template` to `.env` and fill in the Discord application ID, bot token, OAuth client secret, a random `JWT_SECRET` of at least 32 characters, your Discord user ID in `OPERATOR_DISCORD_IDS`, and exact backend/dashboard URLs. Keep `.env` private.
3. In the Discord Developer Portal, enable **Message Content Intent** and add the dashboard's `/callback` and backend's `/oauth/discord-callback` to OAuth redirect URLs.
4. Run `npm run build` then `npm start`. In `dashboard/`, set `VITE_API_URL` to the backend URL, then run `npm run dev` locally or `npm run build` for hosting.
5. Open the landing page and choose **Add bot to a server**. The link uses *your* configured Discord application ID. The invite requests read, send, reactions, attachments, and webhook permissions. Admin tools need additional Discord permissions if enabled.
6. Sign in with Discord and create as many identities as needed, each with its own name and avatar. Request server access and approve it in **Server access**. Copy each identity's MCP URL from the dashboard and connect the corresponding AI client.

The profile name and avatar apply to webhook messages. If an identity has no uploaded avatar, Ashwire uses the Discord bot avatar configured in the Developer Portal. Reactions, direct messages, and polls use the underlying bot identity because Discord does not allow a webhook identity for those actions. ChatGPT still decides when to call a tool; Ashwire does not autonomously reply to every Discord message.

Identity owners can pick an accent color in Ashwire; it colors identity names and portraits in the dashboard and server access views. Discord does not offer a color field for webhook message author names, so those names remain controlled by Discord even when a server role is colored. The server access page keeps each identity's channel settings in a collapsible tray, with pending requests open by default.

The MCP emoji catalog includes custom emoji from servers approved for the current identity. Cross-server reactions require Ashwire's Use External Emoji permission in the destination channel; Discord ultimately decides whether an external emoji renders in a webhook message. Normal messages and image captions can ping one named Discord user with `ping_user_id` or an approved identity role with `ping_role_id`; other mentions remain suppressed. `list_discord_channels` provides the identity roles approved in each channel. `reply_discord_message` preserves the identity's webhook name and avatar, with a short quoted card linking to the original post and no raw URL in the message text. It can optionally ping the original human author or an approved identity role. Discord's Execute Webhook API has no native reply field. `native_reply_discord_message` is an explicit alternative that appears as the shared Ashwire bot.

Outgoing Discord text retains the line breaks and Markdown supplied by the MCP client. When a client sends long plain prose as one line, Ashwire adds paragraph spacing at sentence boundaries for readability. Messages with deliberate line breaks, lists, or code blocks keep their layout.

## Cloudflare target

Ashwire is the host for many identities and eventually many service adapters. Riven is one identity inside it. The current backend is inherited Node.js/SQLite code and is a local prototype; it cannot be deployed unchanged as a Cloudflare Worker. The target is one Cloudflare-hosted app: Workers for the dashboard and MCP/API, D1 for accounts and entity configuration, R2 for avatars, and a Durable Object for the Discord Gateway if we preserve Arachne-style live message routing. This is a port, not a configuration switch.

Cloudflare's Free plan supports Workers, D1, and SQLite-backed Durable Objects within usage limits. A persistent *outbound* Discord Gateway WebSocket cannot hibernate and may be evicted after the platform's connection lifetime window; reconnection and session resume need explicit engineering and live testing. The free tier is a target for the first pilot, not an unlimited hosting guarantee. The existing Arachne bot stays connected during testing.

## Architecture path

The first slice proves Discord end to end. The next change will extract a service-adapter contract with a shared identity, connection, capability, and grant model. Each adapter will declare its tools and permissions, handle its own OAuth/API connection and events, and register tools with the MCP endpoint. Custom-built services can implement that contract. No adapter gets access to another service's tokens or permissions.

## License and attribution

This repository is derived from SolanceLab's Arachne Discord MCP and remains under [AGPL-3.0](LICENSE). Preserve source notices and provide the corresponding source to users of a network-hosted modified version.