Metadata-Version: 2.5
Name: langchain-simplepages
Version: 0.1.0
Summary: LangChain tools for Simplepages: build, edit, and measure landing pages via the hosted Simplepages MCP server.
Project-URL: Homepage, https://simplepages.ai/mcp
Project-URL: Repository, https://github.com/simplepages-ai/langchain-simplepages
Project-URL: Documentation, https://github.com/simplepages-ai/langchain-simplepages#readme
Project-URL: Issues, https://github.com/simplepages-ai/langchain-simplepages/issues
Author-email: Simplepages <support@simplepages.ai>
License: MIT License
        
        Copyright (c) 2026 Simplepages
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,landing-pages,langchain,mcp,simplepages,tools
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: langchain-core<2.0.0,>=1.3.3
Requires-Dist: langchain-mcp-adapters<1.0.0,>=0.3.0
Description-Content-Type: text/markdown

# langchain-simplepages

LangChain tools for [Simplepages](https://simplepages.ai), an AI landing page and
website builder. Your agent can build a page, edit it, and read how it performed.

The package is a thin adapter over the hosted Simplepages MCP server. It discovers
whatever tools the server advertises and hands them back as ordinary LangChain
`BaseTool` objects, with names, descriptions and JSON schemas passed through
untouched.

## Install

```bash
pip install langchain-simplepages
```

## Get a token

Sign in to Simplepages, open **Settings > MCP access**, and generate a token. Then:

```bash
export SIMPLEPAGES_TOKEN="..."
```

Full details at [simplepages.ai/mcp](https://simplepages.ai/mcp).

## Use it

```python
import asyncio
from langchain.agents import create_agent
from langchain_simplepages import SimplepagesToolkit


async def main():
    tools = await SimplepagesToolkit().get_tools()
    agent = create_agent("claude-sonnet-4-5-20250929", tools=tools)
    result = await agent.ainvoke(
        {
            "messages": [
                {
                    "role": "user",
                    "content": "Build a landing page for a Leeds accounting firm that files "
                    "year-end tax returns for freelancers. CTA: book a 20-minute call.",
                }
            ]
        }
    )
    print(result["messages"][-1].content)


asyncio.run(main())
```

`SimplepagesToolkit()` reads `SIMPLEPAGES_TOKEN` from the environment. Pass
`api_key="..."` to override it.

## Tools

| Tool | Read-only | What it does |
| --- | --- | --- |
| `create_page` | no | Generates a new landing page (HTML and AI images) from a description. Saved as a draft. |
| `edit_page` | no | Changes an existing page from a plain-language instruction. Saved to the draft. |
| `list_pages` | yes | Lists standalone landing pages, with publish status and URLs. |
| `list_sites` | yes | Lists multi-page websites, including each site's pages. |
| `get_page` | yes | Returns one page's name, status, edit URL and live URL. |
| `get_page_analytics` | yes | Visitors, views, traffic sources, devices, countries, leads and revenue for one page. |
| `get_workspace_analytics` | yes | Workspace-wide totals and a per-page ranking by visitors and leads. |

**Nothing publishes on its own.** `create_page` and `edit_page` write to a draft.
A page goes live only when someone publishes it from the Simplepages dashboard, so
an agent that gets carried away cannot put anything in front of your visitors.

### Restricting the tool set

`tool_filter` takes a collection of names or a predicate. To give an agent read
access and nothing more:

```python
toolkit = SimplepagesToolkit(
    tool_filter=[
        "list_pages",
        "list_sites",
        "get_page",
        "get_page_analytics",
        "get_workspace_analytics",
    ],
)
```

## Configuration

| Argument | Default | Notes |
| --- | --- | --- |
| `api_key` | `$SIMPLEPAGES_TOKEN` | Stored as a `SecretStr`, so it stays out of reprs and logs. |
| `base_url` | `https://simplepages.ai/api/mcp` | Point at staging or a self-hosted server. |
| `tool_filter` | `None` | Names to keep, or a `Callable[[BaseTool], bool]`. |
| `timeout` | `120.0` | Per-request HTTP timeout in seconds. Page generation is slow. |
| `sse_read_timeout` | `300.0` | Idle timeout for the event stream, in seconds. |

## Sync code

`get_tools()` is async, because the MCP client underneath is. From synchronous
code, use `get_tools_sync()`:

```python
tools = SimplepagesToolkit().get_tools_sync()
```

It raises if called from inside a running event loop, where blocking on the async
client would deadlock. Await `get_tools()` there instead.

## Errors

A missing or rejected token raises `SimplepagesAuthError` (a `ValueError`) naming
the environment variable and where to generate a replacement. Everything else,
including network failures and server errors, propagates unchanged.

## Requirements

Python 3.10 or newer, which is the floor set by `langchain-mcp-adapters`.

## Development

```bash
uv sync --all-groups
uv run pytest tests/unit_tests    # no network, no credentials
uv run ruff check .
uv run mypy langchain_simplepages
```

Integration tests hit the real server and are skipped unless a token is present:

```bash
SIMPLEPAGES_TOKEN=... uv run pytest tests/integration_tests
```

## Links

- [Simplepages MCP docs](https://simplepages.ai/mcp)
- [MCP server manifests](https://github.com/simplepages-ai/simplepages-mcp)
- Registry name: `ai.simplepages/simplepages`

## License

MIT
