# Autonomous Intelligence — Crypto tools for AI agents

The **non-custodial, rug-gated** crypto action layer for AI agents. One connection gives any agent:

| Tool | Key? | What it does |
|------|------|--------------|
| `find_gems` | no | Rug-gated new / trending / graduated tokens |
| `check_token_safety` | no | Honeypot, mint/freeze authority, liquidity lock, holder concentration |
| `get_quote` | no | Best-route swap quote (2% platform fee disclosed) |
| `get_token_info` | no | Live price, liquidity, market cap |
| `list_tradeable_tokens` | no | Every token swappable on the DEX |
| `build_swap` | yes | Returns an **unsigned** tx + `build_id` (agent signs locally) |
| `submit_swap` | yes | Broadcasts a signed tx; honest `confirmed`/`pending`/`failed` |

**Non-custodial by design:** `build_swap` returns an *unsigned* transaction, your agent signs it with the user's own wallet, and `submit_swap` only ever receives an already-signed tx. **Keys never leave the agent's environment.** Discovery tools are open (no key). Base URL: `https://autonomousintelligence.io`.

## Connect over MCP (one line)
```bash
# Claude / Cursor / any MCP client (stdio)
claude mcp add autonomous-intelligence -e AI_AGENT_KEY=YOUR_KEY -- npx -y autonomousintelligence-mcp
# or hosted, no install:
#   https://autonomousintelligence.io/mcp
```

## Get a key (self-serve, for execution only)
```bash
curl -s -X POST https://autonomousintelligence.io/v1/agent/register \
  -H 'content-type: application/json' -d '{"agent_name":"my-agent"}'
# -> { "ok": true, "key": "ai_live_..." }
```

## Drop-in SDK

**JavaScript / TypeScript** — copy [`ai-agent-tools.mjs`](./ai-agent-tools.mjs) (zero deps):
```js
import { openaiTools, execute, register } from './ai-agent-tools.mjs';
const tools = openaiTools();                 // pass to any OpenAI/Anthropic tool loop
const q = await execute('get_quote', { inputMint, outputMint, amount: '10000000' });
```

**Python** — copy [`ai_agent_tools.py`](./ai_agent_tools.py) (stdlib only):
```python
from ai_agent_tools import openai_tools, execute, register
tools = openai_tools()
q = execute("get_quote", {"inputMint": IN, "outputMint": OUT, "amount": "10000000"})
```

### Framework wiring
All frameworks reuse `execute(name, args, {apiKey})` + the JSON schemas from `openaiTools()`.

**OpenAI / Anthropic function-calling** — pass `openaiTools()` as `tools`; on a tool call, run `execute(name, JSON.parse(args), { apiKey })` and return the JSON.

**LangChain (JS)**
```js
import { DynamicStructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
import { TOOLS, execute } from './ai-agent-tools.mjs';
const key = process.env.AI_AGENT_KEY;
export const aiTools = TOOLS.map(t => new DynamicStructuredTool({
  name: t.name, description: t.description, schema: z.object({}).passthrough(),
  func: async (a) => JSON.stringify(await execute(t.name, a, { apiKey: key })),
}));
```

**LangChain (Python)**
```python
from langchain_core.tools import StructuredTool
from ai_agent_tools import TOOLS, execute
key = "ai_live_..."
ai_tools = [StructuredTool.from_function(
    name=t["name"], description=t["description"],
    func=(lambda n: lambda **a: execute(n, a, api_key=key))(t["name"]),
) for t in TOOLS]
```

**Vercel AI SDK**
```js
import { tool } from 'ai'; import { z } from 'zod';
import { TOOLS, execute } from './ai-agent-tools.mjs';
const key = process.env.AI_AGENT_KEY;
export const aiTools = Object.fromEntries(TOOLS.map(t => [t.name,
  tool({ description: t.description, parameters: z.object({}).passthrough(),
         execute: (a) => execute(t.name, a, { apiKey: key }) })]));
```

**LlamaIndex (Python)** — wrap each `execute` call in a `FunctionTool.from_defaults(...)`.
**CrewAI** — subclass `BaseTool` per tool and call `execute(...)` in `_run`.
**ElizaOS / Virtuals GAME** — register each tool as an action whose handler calls the REST rail (or point the agent at the hosted MCP `https://autonomousintelligence.io/mcp`).

## Non-custodial swap flow
```
get_quote  ->  build_swap (unsigned tx + build_id)  ->  [sign locally with the user's wallet]  ->  submit_swap
```
The 2% fee is included inside the built transaction. `submit_swap` verifies the signed tx matches a build issued to your key, broadcasts it, and reports the real confirmation status.

## Discovery / distribution (machine-readable)
- OpenAPI: `https://autonomousintelligence.io/openapi.json`
- llms.txt: `https://autonomousintelligence.io/llms.txt`
- Plugin manifest: `https://autonomousintelligence.io/.well-known/ai-plugin.json`
- MCP registry manifest: [`../mcp/server.json`](../mcp/server.json)

### Submit-to-registries checklist (do in this order)
1. **Publish the npm package** `autonomousintelligence-mcp` (prerequisite for `npx` + the registry).
2. **Official MCP Registry** (`registry.modelcontextprotocol.io`) — publish `mcp/server.json` (GitHub-verified namespace `io.github/...`). Auto-ingested by Glama, MCP.so, Cline, Smithery.
3. **Glama** — "Submit Server" (auto-indexes the GitHub repo; adds a security score + one-click install).
4. **Cline Marketplace** — open a GitHub issue in `cline/mcp-marketplace` with the repo URL + logo.
5. **MCP.so** — GitHub-issue submission.

> `mcp/server.json`'s `$schema` date should be validated against the current registry schema before `mcp publish`.
