# Frameworks

Building your own agent? Give it our MCP server and it gets three tools: `take_screenshot`, `list_countries` and `get_credits`. Each example below is the smallest piece of code that connects one framework to the server.

They all read your key from the environment variable `LOCALSCREENSHOT_API_KEY`:

```bash
export LOCALSCREENSHOT_API_KEY="your key"
```

The server is at `https://api.localscreenshot.com/mcp`, speaks MCP over HTTP, and expects your key in the `Authorization` header. A framework that is not listed here works the same way if its MCP client can send a header.

Under each example, one line says how far we checked it: **Tested** means the code below connected and took a screenshot, **Connected** means it connected and listed our tools, and the rest come from the framework's own documentation. The model names in the examples are placeholders: use the model you already use.

### LangChain

An MCP adapter whose tools you give to your agent.

```bash
pip install "langchain[mcp]"
```

```python
import asyncio
import os

from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter

async def main():
    client = Client("https://api.localscreenshot.com/mcp", auth=os.environ["LOCALSCREENSHOT_API_KEY"])
    async with MCPAdapter(client) as adapter:
        tools = await adapter.list_tools()
        # Any chat model LangChain supports.
        agent = create_agent("claude-opus-5-5", tools)
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "Take a screenshot of wikipedia.org"}]}
        )
        print(result["messages"][-1].content)

asyncio.run(main())
```

Tested: we took a screenshot through it. Source: [docs.langchain.com](https://docs.langchain.com/oss/python/langchain/mcp/auth).

### Claude API

The MCP connector of the Messages API: Claude calls our server for you.

```bash
pip install anthropic
```

```python
import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    messages=[{"role": "user", "content": "Take a screenshot of wikipedia.org"}],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://api.localscreenshot.com/mcp",
            "name": "localscreenshot",
            "authorization_token": os.environ["LOCALSCREENSHOT_API_KEY"],
        }
    ],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "localscreenshot"}],
    betas=["mcp-client-2025-11-20"],
)

for block in response.content:
    if block.type == "text":
        print(block.text)
```

From its documentation, not tried by us yet. Source: [platform.claude.com](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector).

### OpenAI Agents SDK

A Streamable HTTP MCP server for your agent.

```bash
pip install openai-agents
```

```python
import asyncio
import os

from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="localscreenshot",
        params={
            "url": "https://api.localscreenshot.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['LOCALSCREENSHOT_API_KEY']}"},
            "timeout": 60,
        },
        client_session_timeout_seconds=60,
    ) as server:
        agent = Agent(
            name="Assistant",
            instructions="Use the localscreenshot tools to take screenshots.",
            mcp_servers=[server],
        )
        result = await Runner.run(agent, "Take a screenshot of wikipedia.org")
        print(result.final_output)

asyncio.run(main())
```

Tested: we took a screenshot through it. Source: [openai.github.io](https://openai.github.io/openai-agents-python/mcp/).

### Vercel AI SDK

An MCP client whose tools you pass to generateText or streamText.

```bash
npm install ai @ai-sdk/mcp
```

```javascript
import { createMCPClient } from '@ai-sdk/mcp';

const mcpClient = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://api.localscreenshot.com/mcp',
    headers: { Authorization: `Bearer ${process.env.LOCALSCREENSHOT_API_KEY}` },
  },
});

// Pass these to generateText({ model, tools, prompt }) or streamText.
const tools = await mcpClient.tools();

// ...

await mcpClient.close();
```

Tested: we took a screenshot through it. Source: [ai-sdk.dev](https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools).

### CrewAI

An MCP server on your agent.

```bash
pip install crewai
```

```python
import os

from crewai import Agent
from crewai.mcp import MCPServerHTTP

agent = Agent(
    role="Screenshot taker",
    goal="Take screenshots of public web pages",
    backstory="Uses localscreenshot to see web pages.",
    mcps=[
        MCPServerHTTP(
            url="https://api.localscreenshot.com/mcp",
            headers={"Authorization": f"Bearer {os.environ['LOCALSCREENSHOT_API_KEY']}"},
            streamable=True,
        ),
    ],
)
```

Connected: we added our server to it and it listed our tools. Source: [docs.crewai.com](https://docs.crewai.com/en/mcp/overview).

### Pydantic AI

An MCP toolset for your agent.

```bash
pip install "pydantic-ai-slim[mcp]"
```

```python
import os

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset

toolset = MCPToolset(
    "https://api.localscreenshot.com/mcp",
    headers={"Authorization": f"Bearer {os.environ['LOCALSCREENSHOT_API_KEY']}"},
)
# Any model Pydantic AI supports.
agent = Agent("anthropic:claude-opus-5-5", toolsets=[toolset])

result = agent.run_sync("Take a screenshot of wikipedia.org")
print(result.output)
```

Tested: we took a screenshot through it. Source: [pydantic.dev](https://pydantic.dev/docs/ai/mcp/client/).

### Mastra

An MCP client whose tools you give to your agent.

```bash
npm install @mastra/mcp
```

```javascript
import { MCPClient } from '@mastra/mcp';

const mcpClient = new MCPClient({
  servers: {
    localscreenshot: {
      url: new URL('https://api.localscreenshot.com/mcp'),
      requestInit: {
        headers: { Authorization: `Bearer ${process.env.LOCALSCREENSHOT_API_KEY}` },
      },
    },
  },
});

// Pass these to your Agent: new Agent({ ..., tools })
const tools = await mcpClient.listTools();
```

Tested: we took a screenshot through it. Source: [mastra.ai](https://mastra.ai/reference/tools/mcp-client).

### Google ADK

An MCP toolset for your agent.

```bash
pip install google-adk mcp
```

```python
import os

from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams

root_agent = LlmAgent(
    model="gemini-flash-latest",
    name="screenshot_agent",
    instruction="Take screenshots of public web pages with localscreenshot.",
    tools=[
        McpToolset(
            connection_params=StreamableHTTPConnectionParams(
                url="https://api.localscreenshot.com/mcp",
                headers={"Authorization": f"Bearer {os.environ['LOCALSCREENSHOT_API_KEY']}"},
            )
        )
    ],
)
```

Connected: we added our server to it and it listed our tools. Source: [adk.dev](https://adk.dev/tools-custom/mcp-tools/).

## Without a framework

The API is one HTTP request, so you do not need MCP at all when your code decides when to take a screenshot. See [Quickstart](https://docs.localscreenshot.com/quickstart) and [Take a screenshot](https://docs.localscreenshot.com/take). The full description of the API for code generators is at `https://api.localscreenshot.com/v1/openapi.json`.
