# McpServer

> Hosted MCP servers: your tools at one URL for any MCP client.

```python
server = noclick.McpServer.from_name("crm-tools", tools=["hubspot", "search"], create_if_missing=True)
print(server.url)   # paste into Claude, ChatGPT, Cursor or any MCP client
```

The tools are the ones a `Toolkit` or an agent takes (connections, single
operations, `search` and `fetch`), served over Streamable HTTP. Calls act in
the server's user's connections, under your policy, and bill like toolkit calls.
A name that is no connection there serves an integration's operations that need
no account, on NoClick's key: `tools=["exa.search"]` needs no connection.

## noclick.McpServer

```python
class McpServer
```

Your tools at one URL, for Claude, ChatGPT, Cursor or any MCP client.
Anyone with `url` can call the tools, so keep it like a key and
`rotate()` it if it leaks. `tool_count` is how many tools the server
serves right now (a connection's operations count one each; a connection
that isn't connected serves none); `last_client_at` is when any client last
talked to it.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `url` | `str` | The URL MCP clients connect to; the path is its secret. |
| `tools` | `list[Any]` | What it serves, as you listed it: refs, and `{tool, bind}` for an operation with arguments bound. |
| `tool_count` | `int` |  |
| `user_id` | `str | None` |  |
| `created_at` | `Any` |  |
| `last_client_at` | `Any` | When a client last called it (None until one does). |

### McpServer.create

```python
noclick.McpServer.create(
    name, *, tools, allow_existing=False, user=..., client=None
) -> McpServer
```

Create a server called `name` (unique per account and user; a
duplicate raises `noclick.Conflict` with `existing_id`, or with
`allow_existing=True` returns the server already there, as it is: its tools don't change). `tools` are
what an agent or a `Toolkit` takes: connections (a `Connection` or its
name), single operations (`"hubspot.create_contact"`), `"search"` and
`"fetch"`, or a `Toolkit`, at most 64 tools in all. A name is a connection
in the server's user (the account for an account server), else an integration's
operations that need no account (on NoClick's key), so `"exa.search"` needs no connection.
Operations with arguments bound (`hubspot.only(...).bind(...)`, `ConnectionOperations.bind`)
keep them out of every client's reach; there `{{user...}}` is the server's user.

Parameters:

- `name` (`str`, required)
- `tools` (`Sequence[Any]`, required)
- `allow_existing` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `McpServer` The new server, with the `url` to give your MCP client.

Usage:

```python
with noclick.as_user("acme"):
    hubspot = noclick.Connection.from_name("hubspot", integration="hubspot", create_if_missing=True)
    server = noclick.McpServer.create("crm-tools", tools=[hubspot, "search"])
print(server.url)
```

### McpServer.from_name

```python
noclick.McpServer.from_name(
    name, *, tools=None, create_if_missing=False, user=..., client=None
) -> McpServer
```

A lazy reference to the server called `name` in the current (or given)
user. Given `tools`, it gets the server and sets them, on every run: an existing server
whose tools differ gets yours. `create_if_missing=True` creates it when there's none;
without it, a missing server raises `noclick.NotFound`. Its URL stays the same either way. Each run is a write: set the tools at
startup or in a setup script, and take the bare `from_name` in request handlers.

Parameters:

- `name` (`str`, required)
- `tools` (`Sequence[Any] | None`, default `None`)
- `create_if_missing` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `McpServer` A server that loads (or is created, or has your tools set) the first time you read a
field. Nothing is sent yet.

Usage:

Serve a user's CRM and web search to their Claude:

```python
server = noclick.McpServer.from_name(
    "crm-tools", tools=["hubspot", "search"], create_if_missing=True, user="acme",
)
print(server.url)
```

Refer to one by name:

```python
server = noclick.McpServer.from_name("crm-tools", user="acme")
print(server.tool_count, server.last_client_at)
```

### McpServer.from_id

```python
noclick.McpServer.from_id(server_id, *, client=None, user=...) -> McpServer
```

A lazy reference to a server by id.

Parameters:

- `server_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).

Returns: `McpServer` A server that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
server = noclick.McpServer.from_id("6f1d8b3a-2c7e-4a9f-b0d5-3e8c1a7f4b92")
for client in server.clients():
    print(client.name, client.last_seen_at)
```

### McpServer.get

```python
noclick.McpServer.get(server_id, *, user=..., client=None) -> McpServer
```

Load a server by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `server_id` (`str`, required)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `McpServer` The server, loaded.

Usage:

```python
server = noclick.McpServer.get("6f1d8b3a-2c7e-4a9f-b0d5-3e8c1a7f4b92")
print(server.name, server.url, server.tools)
```

### McpServer.list

```python
noclick.McpServer.list(
    *, limit=None, user_filter=None, user=..., client=None
) -> list[McpServer]
```

The current user's servers (the account's own outside `as_user`, or those `user_filter` covers).

Parameters:

- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[McpServer]` Every matching server, newest first, fetched page by page.

Usage:

```python
for server in noclick.McpServer.list(user_filter=noclick.ALL_USERS):
    print(server.name, server.user_id, server.tool_count, server.last_client_at)
```

### McpServer.list_page

```python
noclick.McpServer.list_page(
    *, cursor=None, limit=None, user_filter=None, user=..., client=None
) -> Page
```

One page of servers; pass `next_cursor` back as `cursor`.

Parameters:

- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Page` A page whose `data` holds the servers and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.McpServer.list_page(limit=50)
while True:
    for server in page.data:
        print(server.name)
    if page.next_cursor is None:
        break
    page = noclick.McpServer.list_page(limit=50, cursor=page.next_cursor)
```

### McpServer.update

```python
server.update(*, tools=..., name=...) -> McpServer
```

Change what it serves, or its name; the URL stays. A connected client
sees new tools when it next lists them (most do when a session starts).

Parameters:

- `tools` (`Any`, default: unchanged)
- `name` (`Any`, default: unchanged)

Returns: `McpServer` This server, updated.

Usage:

```python
server = noclick.McpServer.from_name("crm-tools", user="acme")
server.update(tools=["hubspot", "search", "fetch"])
```

### McpServer.rotate

```python
server.rotate() -> McpServer
```

Give it a new URL; the old one stops answering at once, so reconnect
your clients with the new one.

Returns: `McpServer` This server, with its new `url`.

Usage:

```python
server = noclick.McpServer.from_name("crm-tools", user="acme")
server.rotate()
print(server.url)
```

### McpServer.clients

```python
server.clients() -> list[McpClient]
```

The MCP clients that have connected, most recently seen first: whether
your agent has actually started using the server, apart from whether the
server is ready.

Returns: `list[McpClient]` Each client's `name` and `version` as it reported them, when it was first and last seen,
and how many tools it listed. An empty list until a client connects.

Usage:

```python
server = noclick.McpServer.from_name("crm-tools", user="acme")
for client in server.clients():
    print(client.name, client.version, client.last_seen_at, client.tool_count)
```

### McpServer.delete

```python
server.delete() -> None
```

Delete the server; its URL stops answering. The connections it served stay.

Usage:

```python
noclick.McpServer.from_name("crm-tools", user="acme").delete()
```

## noclick.McpClient

```python
class McpClient
```

An MCP client that has connected to a server, as it named itself
(`Claude`, `cursor`, `openai-mcp`). `tool_count` is how many tools
it saw when it last listed them: fewer than the server serves means it
listed them before you added some, and most clients list again only when a
session starts.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `str` |  |
| `version` | `str | None` |  |
| `first_seen_at` | `Any` |  |
| `last_seen_at` | `Any` |  |
| `tool_count` | `int | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
