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

# Quickstart

> Get up and running with MCP Rank in minutes

# Quickstart

MCP Rank is a search engine for AI agent tools. Discover relevant MCP servers for any task and let your agents access user data securely.

## Installation

Install the SDK using pip:

```bash theme={null}
pip install mcp-rank
```

## Set Your API Key

Get your API key from the [dashboard](https://mcprank.com/dashboard/api-keys) and set it as an environment variable:

```bash theme={null}
export MCP_RANK_API_KEY="sk_mcp_rank_..."
```

Or use a `.env` file:

```bash theme={null}
MCP_RANK_API_KEY=sk_mcp_rank_...
```

## Your First Search

Search for relevant MCP servers:

```python theme={null}
import asyncio
from mcp_rank import MCPRankClient

async def main():
    async with MCPRankClient(api_key="sk_mcp_rank_...") as client:
        # Search for tools
        results = await client.search("send email")
        
        for server in results["servers"]:
            print(f"{server['name']}: {server['description']}")

asyncio.run(main())
```

## Use with OpenAI/Anthropic

The SDK includes an `Agent` class that wraps OpenAI or Anthropic clients with automatic tool discovery:

```python theme={null}
from openai import OpenAI
from mcp_rank import Agent

# Create an agent with automatic tool discovery
agent = Agent(OpenAI(), api_key="sk_mcp_rank_...")

# Run a task - tools are discovered and used automatically
response = agent.run("Search the web for latest AI news")
print(response)
```

## Access User Data (MCP Identity)

Let your agent access user's Google data (Gmail, Calendar, Drive) through our secure proxy. MCP Rank stores OAuth tokens server-side, so you never handle sensitive credentials.

### Automatic JIT Auth (Recommended)

```python theme={null}
from openai import OpenAI
from mcp_rank import Agent

# Create agent with user_id for server-side token management
agent = Agent(
    OpenAI(),
    api_key="sk_mcp_rank_...",
    user_id="user_123",   # Your user's ID in your system
    auto_auth=True,       # Opens browser when auth needed
)

# If the task needs Google access:
# 1. Browser opens automatically for OAuth
# 2. User authorizes (tokens stored server-side)
# 3. Request completes
response = agent.run("Send an email to team@company.com about the meeting")
print(response)
```

### Manual Control

For custom UIs or more control over the auth flow:

```python theme={null}
from mcp_rank import MCPRankClient

async def main():
    client = MCPRankClient(
        api_key="sk_mcp_rank_...",
        user_id="user_123",
    )
    
    # Initialize - gets MCP Identity Token from server
    await client.initialize()
    
    # Check if user has connected Google
    info = await client.get_proxy_info("google")
    
    if not info["can_access"]:
        # Create auth session
        session = await client.create_auth_session("google")
        print(f"Please open: {session['auth_url']}")
        
        # Poll for completion (or redirect in web app)
        while True:
            status = await client.check_session_status(session["session_id"])
            if status["status"] == "complete":
                break
            await asyncio.sleep(1)
        
        # Refresh tokens after auth
        await client.initialize()
    
    # Make API calls on behalf of the user
    profile = await client.proxy_get("google", "gmail/v1/users/me/profile")
    print(f"User email: {profile['emailAddress']}")

asyncio.run(main())
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Search" icon="magnifying-glass" href="/sdk/search">
    Learn about semantic search for MCP servers
  </Card>

  <Card title="MCP Identity" icon="fingerprint" href="/sdk/identity">
    Set up user authentication and data access
  </Card>

  <Card title="OAuth Proxy" icon="shield" href="/sdk/proxy">
    Make API calls on behalf of users
  </Card>

  <Card title="API Reference" icon="code" href="/api/overview">
    Full REST API documentation
  </Card>
</CardGroup>
