> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.to/llms.txt
> Use this file to discover all available pages before exploring further.

# Work with AI

> Use Struct with AI agents, coding assistants, and autonomous workflows.

Struct is designed to work natively with AI tools. Whether you're building autonomous agents, using an AI coding assistant, or integrating prediction market data into an AI workflow, there's a first-class path for you.

<CardGroup cols={3}>
  <Card title="TypeScript SDK" icon="js" href="#typescript-sdk">
    Type-safe client with full autocompletion.
  </Card>

  <Card title="MCP Server" icon="plug" href="#mcp-server">
    Connect AI assistants directly to Struct data.
  </Card>

  <Card title="AI Skill" icon="wand-magic-sparkles" href="#ai-skill">
    Install via skills.sh for instant access in your agent.
  </Card>
</CardGroup>

## TypeScript SDK

The Struct SDK gives you a fully typed client for all Polymarket endpoints. Install it and start querying in seconds.

```bash theme={null}
npm install @structbuild/sdk
```

```typescript theme={null}
import { StructClient } from "@structbuild/sdk";

const client = new StructClient({ apiKey: "YOUR_API_KEY" });

const markets = await client.markets.getMarkets();

const event = await client.events.getEventBySlug({ slug: "us-presidential-election" });
```

Every method returns fully typed responses, with no manual type definitions and no guessing field names.

<Card title="SDK Reference" icon="book" href="https://www.npmjs.com/package/@structbuild/sdk">
  Full documentation, examples, and source code.
</Card>

## MCP Server

Struct exposes a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that lets AI assistants query prediction market data directly. The MCP server is available at `api.struct.to/mcp` and supports two authentication methods.

### OAuth (for AI assistants)

For AI assistants like ChatGPT and Claude that support OAuth-based MCP connections, simply connect using the MCP URL:

```
https://api.struct.to/mcp
```

The assistant will handle the OAuth flow automatically, so no API key management is needed.

### API Key (for backend agents)

For backend AI agents and programmatic access, connect to the MCP server directly with your API key:

```json theme={null}
{
  "mcpServers": {
    "struct": {
      "url": "https://api.struct.to/mcp?api_key=YOUR_API_KEY"
    }
  }
}
```

Once connected, your AI agent can search markets, pull real-time prices, look up trader positions, and more, all through natural language.

## AI Skill

Install the Struct skill to give any Claude Code agent instant access to Struct's Polymarket data.

```bash theme={null}
npx skills add structbuild/struct-skill
```

Once installed, the agent can query markets, events, trades, and positions without any additional setup.

## Choose Your Path

| Approach                 | Best For                                        |
| ------------------------ | ----------------------------------------------- |
| **REST API**             | Full control, any language, custom integrations |
| **TypeScript SDK**       | TypeScript/JavaScript projects with type safety |
| **MCP Server (OAuth)**   | AI assistants like ChatGPT and Claude           |
| **MCP Server (API Key)** | Backend AI agents and programmatic access       |
| **AI Skill**             | Claude Code agents via skills.sh                |
