mcp agent

Elfa MCP Server

by elfa-ai·MIT license·★ 7 Stars on the repo·GitHub ↗

Files of mcp

elfa-ai/main1 file
README.md
Show the full text213 lines

Elfa MCP

Model Context Protocol server for the Elfa API — crypto social intelligence from X and Telegram, plus Auto, a condition engine that watches the market and fires an action when your conditions are met.

Works with any MCP client: Claude Code, Claude Desktop, Cursor, VS Code, Codex, and anything else that speaks MCP.

Install

Get an API key at dev.elfa.ai. No install step — npx fetches the server on demand.

One click

Add to Cursor Add to VS Code

Claude Desktop

Download elfa-mcp-<version>.mcpb from the latest release and open it. Claude Desktop installs it, prompts for your API key, and keeps it updated. Nothing else to configure.

Claude Code

claude mcp add elfa --env ELFA_API_KEY=your-key -- npx -y @elfa-ai/mcp

Cursor, VS Code, Claude Desktop, and other clients

{
  "mcpServers": {
    "elfa": {
      "command": "npx",
      "args": ["-y", "@elfa-ai/mcp"],
      "env": {
        "ELFA_API_KEY": "your-key"
      }
    }
  }
}

VS Code uses "servers" instead of "mcpServers". Everything else is the same.

Ask "what's trending in crypto right now?" to confirm it works.

Configuration

Variable Required Purpose
ELFA_API_KEY yes Authenticates every request
ELFA_TIMEOUT no Request timeout in ms, default 120000
ELFA_RETRIES no Retries on failure, default 0
ELFA_MCP_MAX_RESPONSE_CHARS no Response size ceiling, default 60000
ELFA_EXTRA_HEADERS no JSON object of extra headers to send upstream, for proxies and non-production environments

Upstream requests identify themselves as User-Agent: elfa-mcp/<version> (<transport>; client=<app>). On stdio, <app> is the MCP client's name and version from the handshake; over HTTP, it is the connecting client's own User-Agent header. Set User-Agent in ELFA_EXTRA_HEADERS to send your own instead.

The timeout is high and retries are off on purpose. The interpretation endpoints are LLM-backed and can take over a minute, and they cost credits per attempt, so a silent retry would bill you again for a call you never saw. Raise ELFA_RETRIES only if you are calling the cheap measurement endpoints.

Some MCP clients apply their own timeout, often around 60 seconds. narratives and market_chat can exceed that; the request still completes and is still charged, even if the client gives up first.

Tools

11 tools, mapped to every documented /v2 operation.

Tool Mode Cost What it does
api_status read Free Check API key tier, credit usage and remaining requests. Also confirms the API is reachable.
mentions read 1 per call Social mentions from X and Telegram. mode=top ranks a ticker's mentions by engagement, mode=search filters by keyword or account, mode=news returns the token news feed, which is X posts from accounts tagged as news sources rather than articles from news outlets.
trending read 1 per call What is gaining social attention. scope=tokens for tickers, scope=contracts_twitter or scope=contracts_telegram for contract addresses.
narratives read 5 per call Written narrative analysis with source links. scope=market extracts market-wide narratives, scope=keywords summarises events for specific keywords.
account_stats read 1 per call Smart follower and engagement stats for an X account. Legacy: it still works, but will be removed on 28 October 2026.
market_chat read Varies by speed Ask for written market analysis. Supports conversational chat, macro overview, quick summary, token intro, token analysis and account analysis.
auto_build read 1 plus LLM usage Turn a plain-language monitoring request into an EQL query. Returns a draft to validate and activate, it does not activate anything itself.
auto_validate read Free Check EQL syntax and get a cost estimate before activating, or check that a symbol has market data on a venue.
auto_query read Free Read side of Auto: list queries, poll one query, and read its executions and LLM sessions.
auto_query_write write 5 plus LLM usage to create, free to cancel or delete Activate, cancel or delete an Auto query. Activated queries run unattended and fire their action when conditions are met.
auto_draft write Free, except convert which costs the same as creating a query Manage inactive Auto drafts. Drafts do not evaluate until converted into an active query.

Not exposed as tools:

  • chat-stream-v2 — A tool call returns one result, so streaming adds nothing. market_chat covers the same analysis.
  • auto-stream-queries-v2 — Long lived streams have no tool equivalent. Poll with auto_query.
  • auto-stream-query-v2 — Long lived streams have no tool equivalent. Poll with auto_query.

Some tools depend on the plan: today market_chat, which needs a higher-tier plan than the free one. At startup (stdio) or per request (HTTP, cached for a minute per key), the server reads the key's scopes from /v2/key-status. A tool the plan doesn't include stays listed, but its description says it needs a higher-tier plan, and calling it returns the upgrade link without calling the API or spending credits. If the scopes can't be read within 3 seconds, every tool is listed as usual and the API decides.

Streaming endpoints stay available through the SDKs for applications that can consume SSE.

Where this differs from the raw API

The tools deliberately do not inherit every API default, because an agent pays for verbosity in context.

API Here Why
pageSize 10 to 50 depending on endpoint, max 100 10 Page through rather than pull everything
speed on chat expert fast Cheaper by default, ask for expert when depth matters
Mention fields full record high signal fields Pass verbosity: "detailed" for the rest
Large responses returned whole trimmed to fit, with a note Keeps one call from filling the context window

Every value is still settable per call, and pageSize accepts up to 100.

Auto

Auto queries run unattended. Once armed, a query keeps evaluating and fires its action without asking again.

The flow is three steps:

  1. auto_build — describe what to watch in plain language, get EQL back
  2. auto_validate — check the syntax and get the credit cost
  3. auto_query_write — activate it

Actions can notify you, call a webhook, message a Telegram bot, or run an LLM analysis.

There is no push channel over MCP. Poll auto_query with method=get, and wait for the returned pollAfterSeconds between calls.

Remote server

The same server runs over Streamable HTTP for hosted deployments:

ELFA_MCP_TRANSPORT=http ELFA_MCP_PORT=3000 npx -y @elfa-ai/mcp

It is stateless — no sessions, one server instance per request, safe behind a load balancer. Credentials come from the x-elfa-api-key request header, falling back to the environment, or from an OAuth sign-in (see below).

DNS rebinding protection is on by default. The server accepts only the loopback names it binds — localhost:PORT and 127.0.0.1:PORT — which covers the local run above and nothing else. Any deployment that answers on a different Host must list the values it serves:

ELFA_MCP_ALLOWED_HOSTS=mcp.example.com

That includes a public domain, a reverse proxy, and a container that maps the port to a different one than the server binds. A Host the list does not cover is rejected with 403.

Variable Required Purpose
ELFA_MCP_TRANSPORT no http to serve over Streamable HTTP, default stdio
ELFA_MCP_HOST no Bind address, default 127.0.0.1
ELFA_MCP_PORT no Bind port, default 3000
ELFA_MCP_ALLOWED_HOSTS no Comma separated Host allowlist, defaults to the loopback names bound
ELFA_MCP_ALLOWED_ORIGINS no Comma separated Origin allowlist

Set ELFA_MCP_ALLOWED_ORIGINS as well when browsers call the server directly. It complements the host allowlist rather than replacing it: a rebound request is same origin, so it carries no Origin header for that list to check, and the Host header is the only one still naming the attacker's domain.

OAuth sign-in

A hosted server can let clients sign in through a browser instead of sending an API key. Set ELFA_MCP_AUTH=oauth and the server becomes an OAuth resource server under the MCP authorization spec:

  1. A request with no credential gets 401 and a WWW-Authenticate challenge.
  2. The challenge points the client to the protected-resource metadata at /.well-known/oauth-protected-resource/mcp.
  3. That metadata names the authorization server, where the user signs in.
  4. The client then sends Authorization: Bearer <token>.
  5. The server checks the token against the authorization server's introspection endpoint. The endpoint answers with the Elfa API key the request runs as, so the token never reaches the Elfa API.
ELFA_MCP_TRANSPORT=http \
ELFA_MCP_AUTH=oauth \
ELFA_MCP_RESOURCE_URL=https://mcp.example.com/mcp \
ELFA_OAUTH_ISSUER=https://auth.example.com \
ELFA_OAUTH_INTROSPECTION_URL=https://auth.example.com/introspect \
ELFA_OAUTH_INTROSPECTION_TOKEN=... \
ELFA_MCP_ALLOWED_HOSTS=mcp.example.com \
npx -y @elfa-ai/mcp
Variable Required in OAuth mode Purpose
ELFA_MCP_AUTH yes oauth to enable, default apikey
ELFA_MCP_RESOURCE_URL yes Canonical URL of this endpoint. Tokens must be issued for exactly this value
ELFA_OAUTH_ISSUER yes Authorization server listed in the metadata
ELFA_OAUTH_INTROSPECTION_URL yes Where tokens are checked
ELFA_OAUTH_INTROSPECTION_TOKEN yes Bearer sent to the introspection endpoint
ELFA_OAUTH_SCOPES no Comma separated scopes to advertise, default elfa

Notes:

  • An x-elfa-api-key header still works in OAuth mode.
  • ELFA_API_KEY is ignored in OAuth mode, so a caller with no credential never runs as the server's own key.
  • Valid tokens are cached for up to a minute, which bounds how long a revoked token keeps working.

Safety

api_status is the fastest way to tell an auth problem from a credit problem.

Mentions, news and narratives return third-party social text that anyone can write. The server marks it as untrusted in every response, and the server instructions tell the model to treat it as data. Keep that in mind before letting an agent chain from that content into auto_query_write.

Development

npm install
npm run build
npm run verify

npm run verify runs typecheck, tests, the spec drift check, and the docs check.

manifest.json maps every documented API operation to the tool that covers it. npm run check:drift fails if the API grows an operation the server does not handle. The tool table above is generated from the same file with npm run docs:tools.

License

MIT

1# Elfa MCP
2 
3Model Context Protocol server for the [Elfa API](https://docs.elfa.ai) — crypto social intelligence from X and Telegram, plus **Auto**, a condition engine that watches the market and fires an action when your conditions are met.
4 
5Works with any MCP client: Claude Code, Claude Desktop, Cursor, VS Code, Codex, and anything else that speaks MCP.
6 
7## Install
8 
9Get an API key at [dev.elfa.ai](https://dev.elfa.ai). No install step — `npx` fetches the server on demand.
10 
11**One click**
12 
13[![Add to Cursor](https://img.shields.io/badge/Add%20to-Cursor-000000?style=flat-square)](cursor://anysphere.cursor-deeplink/mcp/install?name=elfa&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBlbGZhLWFpL21jcCJdLCJlbnYiOnsiRUxGQV9BUElfS0VZIjoiJHtpbnB1dDplbGZhQXBpS2V5fSJ9fQ==)
14[![Add to VS Code](https://img.shields.io/badge/Add%20to-VS%20Code-0098FF?style=flat-square)](https://vscode.dev/redirect/mcp/install?name=elfa&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40elfa-ai%2Fmcp%22%5D%2C%22env%22%3A%7B%22ELFA_API_KEY%22%3A%22%24%7Binput%3AelfaApiKey%7D%22%7D%7D)
15 
16**Claude Desktop**
17 
18Download `elfa-mcp-<version>.mcpb` from the [latest release](https://github.com/elfa-ai/mcp/releases/latest) and open it. Claude Desktop installs it, prompts for your API key, and keeps it updated. Nothing else to configure.
19 
20**Claude Code**
21 
22```bash
23claude mcp add elfa --env ELFA_API_KEY=your-key -- npx -y @elfa-ai/mcp
24```
25 
26**Cursor, VS Code, Claude Desktop, and other clients**
27 
28```json
29{
30 "mcpServers": {
31 "elfa": {
32 "command": "npx",
33 "args": ["-y", "@elfa-ai/mcp"],
34 "env": {
35 "ELFA_API_KEY": "your-key"
36 }
37 }
38 }
39}
40```
41 
42VS Code uses `"servers"` instead of `"mcpServers"`. Everything else is the same.
43 
44Ask *"what's trending in crypto right now?"* to confirm it works.
45 
46## Configuration
47 
48| Variable | Required | Purpose |
49| --- | --- | --- |
50| `ELFA_API_KEY` | yes | Authenticates every request |
51| `ELFA_TIMEOUT` | no | Request timeout in ms, default `120000` |
52| `ELFA_RETRIES` | no | Retries on failure, default `0` |
53| `ELFA_MCP_MAX_RESPONSE_CHARS` | no | Response size ceiling, default `60000` |
54| `ELFA_EXTRA_HEADERS` | no | JSON object of extra headers to send upstream, for proxies and non-production environments |
55 
56Upstream requests identify themselves as `User-Agent: elfa-mcp/<version> (<transport>; client=<app>)`. On stdio, `<app>` is the MCP client's name and version from the handshake; over HTTP, it is the connecting client's own `User-Agent` header. Set `User-Agent` in `ELFA_EXTRA_HEADERS` to send your own instead.
57 
58The timeout is high and retries are off on purpose. The interpretation endpoints are LLM-backed and can take over a minute, and they cost credits per attempt, so a silent retry would bill you again for a call you never saw. Raise `ELFA_RETRIES` only if you are calling the cheap measurement endpoints.
59 
60Some MCP clients apply their own timeout, often around 60 seconds. `narratives` and `market_chat` can exceed that; the request still completes and is still charged, even if the client gives up first.
61 
62## Tools
63 
64<!-- tools:start -->
65 
6611 tools, mapped to every documented `/v2` operation.
67 
68| Tool | Mode | Cost | What it does |
69| --- | --- | --- | --- |
70| `api_status` | read | Free | Check API key tier, credit usage and remaining requests. Also confirms the API is reachable. |
71| `mentions` | read | 1 per call | Social mentions from X and Telegram. mode=top ranks a ticker's mentions by engagement, mode=search filters by keyword or account, mode=news returns the token news feed, which is X posts from accounts tagged as news sources rather than articles from news outlets. |
72| `trending` | read | 1 per call | What is gaining social attention. scope=tokens for tickers, scope=contracts_twitter or scope=contracts_telegram for contract addresses. |
73| `narratives` | read | 5 per call | Written narrative analysis with source links. scope=market extracts market-wide narratives, scope=keywords summarises events for specific keywords. |
74| `account_stats` | read | 1 per call | Smart follower and engagement stats for an X account. Legacy: it still works, but will be removed on 28 October 2026. |
75| `market_chat` | read | Varies by speed | Ask for written market analysis. Supports conversational chat, macro overview, quick summary, token intro, token analysis and account analysis. |
76| `auto_build` | read | 1 plus LLM usage | Turn a plain-language monitoring request into an EQL query. Returns a draft to validate and activate, it does not activate anything itself. |
77| `auto_validate` | read | Free | Check EQL syntax and get a cost estimate before activating, or check that a symbol has market data on a venue. |
78| `auto_query` | read | Free | Read side of Auto: list queries, poll one query, and read its executions and LLM sessions. |
79| `auto_query_write` | write | 5 plus LLM usage to create, free to cancel or delete | Activate, cancel or delete an Auto query. Activated queries run unattended and fire their action when conditions are met. |
80| `auto_draft` | write | Free, except convert which costs the same as creating a query | Manage inactive Auto drafts. Drafts do not evaluate until converted into an active query. |
81 
82Not exposed as tools:
83 
84- `chat-stream-v2` — A tool call returns one result, so streaming adds nothing. market_chat covers the same analysis.
85- `auto-stream-queries-v2` — Long lived streams have no tool equivalent. Poll with auto_query.
86- `auto-stream-query-v2` — Long lived streams have no tool equivalent. Poll with auto_query.
87 
88<!-- tools:end -->
89 
90Some tools depend on the plan: today `market_chat`, which needs a higher-tier plan than the free one. At startup (stdio) or per request (HTTP, cached for a minute per key), the server reads the key's scopes from `/v2/key-status`. A tool the plan doesn't include stays listed, but its description says it needs a higher-tier plan, and calling it returns the upgrade link without calling the API or spending credits. If the scopes can't be read within 3 seconds, every tool is listed as usual and the API decides.
91 
92Streaming endpoints stay available through the [SDKs](https://docs.elfa.ai) for applications that can consume SSE.
93 
94### Where this differs from the raw API
95 
96The tools deliberately do not inherit every API default, because an agent pays for verbosity in context.
97 
98| | API | Here | Why |
99| --- | --- | --- | --- |
100| `pageSize` | 10 to 50 depending on endpoint, max 100 | 10 | Page through rather than pull everything |
101| `speed` on chat | `expert` | `fast` | Cheaper by default, ask for `expert` when depth matters |
102| Mention fields | full record | high signal fields | Pass `verbosity: "detailed"` for the rest |
103| Large responses | returned whole | trimmed to fit, with a note | Keeps one call from filling the context window |
104 
105Every value is still settable per call, and `pageSize` accepts up to 100.
106 
107## Auto
108 
109Auto queries run unattended. Once armed, a query keeps evaluating and fires its action without asking again.
110 
111The flow is three steps:
112 
1131. `auto_build` — describe what to watch in plain language, get EQL back
1142. `auto_validate` — check the syntax and get the credit cost
1153. `auto_query_write` — activate it
116 
117Actions can notify you, call a webhook, message a Telegram bot, or run an LLM analysis.
118 
119There is no push channel over MCP. Poll `auto_query` with `method=get`, and wait for the returned `pollAfterSeconds` between calls.
120 
121## Remote server
122 
123The same server runs over Streamable HTTP for hosted deployments:
124 
125```bash
126ELFA_MCP_TRANSPORT=http ELFA_MCP_PORT=3000 npx -y @elfa-ai/mcp
127```
128 
129It is stateless — no sessions, one server instance per request, safe behind a load balancer. Credentials come from the `x-elfa-api-key` request header, falling back to the environment, or from an OAuth sign-in (see below).
130 
131DNS rebinding protection is on by default. The server accepts only the loopback names it binds — `localhost:PORT` and `127.0.0.1:PORT` — which covers the local run above and nothing else. Any deployment that answers on a different `Host` must list the values it serves:
132 
133```bash
134ELFA_MCP_ALLOWED_HOSTS=mcp.example.com
135```
136 
137That includes a public domain, a reverse proxy, and a container that maps the port to a different one than the server binds. A `Host` the list does not cover is rejected with 403.
138 
139| Variable | Required | Purpose |
140| --- | --- | --- |
141| `ELFA_MCP_TRANSPORT` | no | `http` to serve over Streamable HTTP, default `stdio` |
142| `ELFA_MCP_HOST` | no | Bind address, default `127.0.0.1` |
143| `ELFA_MCP_PORT` | no | Bind port, default `3000` |
144| `ELFA_MCP_ALLOWED_HOSTS` | no | Comma separated `Host` allowlist, defaults to the loopback names bound |
145| `ELFA_MCP_ALLOWED_ORIGINS` | no | Comma separated `Origin` allowlist |
146 
147Set `ELFA_MCP_ALLOWED_ORIGINS` as well when browsers call the server directly. It complements the host allowlist rather than replacing it: a rebound request is same origin, so it carries no `Origin` header for that list to check, and the `Host` header is the only one still naming the attacker's domain.
148 
149### OAuth sign-in
150 
151A hosted server can let clients sign in through a browser instead of sending an API key. Set `ELFA_MCP_AUTH=oauth` and the server becomes an OAuth resource server under the MCP authorization spec:
152 
1531. A request with no credential gets `401` and a `WWW-Authenticate` challenge.
1542. The challenge points the client to the protected-resource metadata at `/.well-known/oauth-protected-resource/mcp`.
1553. That metadata names the authorization server, where the user signs in.
1564. The client then sends `Authorization: Bearer <token>`.
1575. The server checks the token against the authorization server's introspection endpoint. The endpoint answers with the Elfa API key the request runs as, so the token never reaches the Elfa API.
158 
159```bash
160ELFA_MCP_TRANSPORT=http \
161ELFA_MCP_AUTH=oauth \
162ELFA_MCP_RESOURCE_URL=https://mcp.example.com/mcp \
163ELFA_OAUTH_ISSUER=https://auth.example.com \
164ELFA_OAUTH_INTROSPECTION_URL=https://auth.example.com/introspect \
165ELFA_OAUTH_INTROSPECTION_TOKEN=... \
166ELFA_MCP_ALLOWED_HOSTS=mcp.example.com \
167npx -y @elfa-ai/mcp
168```
169 
170| Variable | Required in OAuth mode | Purpose |
171| --- | --- | --- |
172| `ELFA_MCP_AUTH` | yes | `oauth` to enable, default `apikey` |
173| `ELFA_MCP_RESOURCE_URL` | yes | Canonical URL of this endpoint. Tokens must be issued for exactly this value |
174| `ELFA_OAUTH_ISSUER` | yes | Authorization server listed in the metadata |
175| `ELFA_OAUTH_INTROSPECTION_URL` | yes | Where tokens are checked |
176| `ELFA_OAUTH_INTROSPECTION_TOKEN` | yes | Bearer sent to the introspection endpoint |
177| `ELFA_OAUTH_SCOPES` | no | Comma separated scopes to advertise, default `elfa` |
178 
179Notes:
180 
181- An `x-elfa-api-key` header still works in OAuth mode.
182- `ELFA_API_KEY` is ignored in OAuth mode, so a caller with no credential never runs as the server's own key.
183- Valid tokens are cached for up to a minute, which bounds how long a revoked token keeps working.
184 
185## Safety
186 
187`api_status` is the fastest way to tell an auth problem from a credit problem.
188 
189 
190Mentions, news and narratives return third-party social text that anyone can write. The server marks it as untrusted in every response, and the server instructions tell the model to treat it as data. Keep that in mind before letting an agent chain from that content into `auto_query_write`.
191 
192## Development
193 
194```bash
195npm install
196npm run build
197npm run verify
198```
199 
200`npm run verify` runs typecheck, tests, the spec drift check, and the docs check.
201 
202`manifest.json` maps every documented API operation to the tool that covers it. `npm run check:drift` fails if the API grows an operation the server does not handle. The tool table above is generated from the same file with `npm run docs:tools`.
203 
204## Links
205 
206- [Documentation](https://docs.elfa.ai)
207- [API keys](https://dev.elfa.ai)
208- [TypeScript SDK](https://www.npmjs.com/package/@elfa-ai/sdk)
209 
210## License
211 
212MIT
213 

Discussion

Alternatives