Metadata-Version: 2.4
Name: simplemcp-framework
Version: 2.1.9
Summary: A Docker-powered MCP server framework — extend with drop-in kit files and connect to Claude Desktop, LM Studio, OpenWebUI, and more.
Author: dwhite-sys
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship made available under
              the License, as indicated by a copyright notice that is included in
              or attached to the work (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean, as submitted to the Licensor for inclusion
              in the Work by the copyright owner or by an individual or Legal Entity
              authorized to submit on behalf of the copyright owner. For the purposes
              of this definition, "submitted" means any form of electronic, verbal,
              or written communication sent to the Licensor or its representatives,
              including but not limited to communication on electronic mailing lists,
              source code control systems, and issue tracking systems that are managed
              by, or on behalf of, the Licensor for the purpose of discussing and
              improving the Work, but excluding communication that is conspicuously
              marked or otherwise designated in writing by the copyright owner as
              "Not a Contribution."
        
              "Contributor" shall mean Licensor and any Legal Entity on behalf of
              whom a Contribution has been received by the Licensor and subsequently
              incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a cross-claim
              or counterclaim in a lawsuit) alleging that the Work or a Contribution
              incorporated within the Work constitutes direct or contributory patent
              infringement, then any patent licenses granted to You under this License
              for that Work shall terminate as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or Derivative Works
                  a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, You must include a readable copy of the attribution
                  notices contained within such NOTICE file, in at least one of
                  the following places: within a NOTICE text file distributed as
                  part of the Derivative Works; within the Source form or documentation,
                  if provided along with the Derivative Works; or, within a display
                  generated by the Derivative Works, if and wherever such third-party
                  notices normally appear. The contents of the NOTICE file are for
                  informational purposes only and do not modify the License. You may
                  add Your own attribution notices within Derivative Works that You
                  distribute, alongside or as an addendum to the NOTICE text from
                  the Work, provided that such additional attribution notices cannot
                  be construed as modifying the License.
        
              You may add Your own license statement for Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for such other Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or agreed
              to in writing, Licensor provides the Work (and each Contributor provides
              its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
              OF ANY KIND, either express or implied, including, without limitation,
              any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
              or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
              determining the appropriateness of using or reproducing the Work and
              assume any risks associated with Your exercise of permissions under
              this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or exemplary damages of any character arising as a result
              of this License or out of the use or inability to use the Work
              (including but not limited to damages for loss of goodwill, work
              stoppage, computer failure or malfunction, or all other commercial
              damages or losses), even if such Contributor has been advised of the
              possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing the
              Work or Derivative Works thereof, You may choose to offer, and charge
              a fee for, acceptance of support, warranty, indemnity, or other liability
              obligations and/or rights consistent with this License. However, in
              accepting such obligations, You may act only on Your own behalf and on
              Your sole responsibility, not on behalf of any other Contributor, and
              only if You agree to indemnify, defend, and hold each Contributor harmless
              for any liability incurred by, or claims asserted against, such Contributor
              by reason of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2026 dwhite-sys
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/dwhite-sys/SimpleMCP
Project-URL: Repository, https://github.com/dwhite-sys/SimpleMCP
Keywords: mcp,model context protocol,llm,tools,docker,claude,openwebui,lm studio,stdio,kit
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docker
Dynamic: license-file

# SimpleMCP V2

A Docker-powered MCP-compatible tool server you extend with drop-in kit files — no server code to touch, no venvs to manage. Drop a `_kit.py` file in, install it with one command, and it's live.

## How it works

- **CLI** (`simplemcp`): Manages the full lifecycle — install kits, start/stop/restart/rebuild the server, configure client integrations, manage the CDP browser broker.
- **Docker container**: The server runs in an isolated container built from a bundled Dockerfile. On first `simplemcp start`, the image is built automatically. Use `simplemcp rebuild --pull` to pull the latest precompiled image from `ghcr.io/dwhite-sys/simplemcp`.
- **Kits** (`~/.simplemcp/kits/`): Each kit is a plain Python file with `@tool`-decorated functions and four metadata fields. The container mounts this directory as a volume — kits are live without rebuilding.
- **`bootstrap.py`**: Runs inside the container on every start. Clears `__pycache__` so edits to kit files are always picked up fresh. AST-parses each kit's `requirements` list and installs anything missing via `uv pip`. Starts the socat CDP proxy (`localhost:9222 → host.docker.internal:9222`) for the Playwright kit. Execs the real server when done.
- **`server.py`**: FastAPI server inside the container. Auto-discovers all kits at startup, and again on hot-reload. Speaks both SimpleMCP protocol and MCP JSON-RPC on the same port — no mode flag needed. Each kit also gets its own dedicated MCP port (base port + 1, +2, … per kit) for per-kit stdio shim connections.
- **`utils/registry.py`**: The `@tool` decorator registers functions into a global dict. Type hints are scraped to build JSON Schema for each tool's input automatically.
- **`stdio_shim.py`**: Thin bridge that translates MCP JSON-RPC from stdin to the already-running container's HTTP API. One shim process per kit entry in the client config, all sharing the same container.
- **Config** (`~/.simplemcp/config.json`): Tracks installed kits, running port, container ID, and per-kit port assignments. Written and read exclusively by the CLI.
- **Kit configs** (`~/.simplemcp/kit_configs/<kit_stem>/config.json`): Per-kit config values. Populated from the kit's `config = {}` dict on install (preserving any values the user has already set), volume-mounted into the container at runtime.

## Kit anatomy

```python
# my_kit.py
from utils import tool

kit_name        = "My Tools"
kit_description = "What this kit does."
requirements    = ["requests", "some-package"]
config          = {"MY_VAR": "default_value"}

@tool
def do_something(query: str, limit: int = 10):
    """
    Does something cool with a query.

    query: The search query to use.
    limit: Maximum number of results (default 10).

    Returns {"result": str, "count": int}.
    """
    my_var = os.getenv("MY_VAR", "default_value")
    return {"result": "stuff", "count": limit}
```

- `kit_name` and `kit_description` are displayed by the protocol, `simplemcp list`, and client UIs.
- `requirements` is AST-parsed by `bootstrap.py` — no import needed. Missing packages are installed on container start, or immediately into a live container on `simplemcp install`.
- `config` is a dict of `{"VAR_NAME": "default"}` pairs. Values are stored in `~/.simplemcp/kit_configs/<kit_stem>/config.json`, volume-mounted into the container, and available as environment variables. User-set values are preserved across reinstalls.
- `@tool` is the only import required. Type hints are mandatory — they build the JSON Schema. Docstrings become the tool description shown to the model; write them for the model, not for humans.

## Server protocol

One container, one port, both protocols always running. Each kit also gets its own dedicated MCP port for per-kit stdio connections.

### SimpleMCP protocol

| Endpoint | Method | Body | Description |
|---|---|---|---|
| `/list_kits` | GET | — | All installed kit names and descriptions |
| `/inspect_kit` | POST | `{"kit": "Name"}` | Kit metadata (name, description, tool count) |
| `/list_tools_in_kit` | POST | `{"kit": "Name"}` | Full tool schemas for a kit |
| `/inspect_tool` | POST | `{"tool": "fn_name"}` | Schema for a single tool |
| `/run_tool` | POST | `{"tool": "fn_name", "arguments": {...}}` | Execute a tool, returns result directly |
| `/reload_kit` | POST | `{"kit_stem": "my_kit"}` | Hot-reload a kit without restart |

### MCP protocol (JSON-RPC 2.0)

| Endpoint | Method | Description |
|---|---|---|
| `/mcp` | POST | Handles `initialize`, `tools/list`, `tools/call` |
| `/mcp` | GET | SSE keepalive stream |

The `/mcp` endpoint accepts an optional `X-SimpleMCP-Kit` header to scope tool listings and calls to a single kit — used automatically by the stdio shim.

### Per-kit MCP ports

Each installed kit gets its own MCP port (e.g. kit 1 → 8468, kit 2 → 8469, …). The same `/mcp` endpoint is served on each port, pre-scoped to that kit. This is what `simplemcp compat` uses when writing client configs — each kit gets its own stdio shim pointed at its dedicated port.

## stdio mode

`simplemcp start stdio [kit_name]` runs a shim process that bridges MCP JSON-RPC from stdin to the already-running container's per-kit MCP port. The container must already be running.

- No per-connection container spawning — zero overhead per client connect
- Multiple shim processes share the same container
- Each shim targets a specific kit's dedicated port, so tool listings are automatically scoped
- Omit `kit_name` to connect to the main port (all kits)

## CLI reference

```
simplemcp install <path/to/kit.py>              Install or update a kit
simplemcp remove <kit_name>                     Remove a kit
simplemcp list                                  List installed kits and status

simplemcp start                                 Start the server (progress bar)
simplemcp start --verbose                       Start with full log output
simplemcp start stdio                           Start stdio shim (all kits)
simplemcp start stdio <kit_name>                Start stdio shim (single kit)
simplemcp stop                                  Stop the server
simplemcp restart                               Restart the server

simplemcp rebuild                               Build image locally and restart
simplemcp rebuild --pull                        Pull precompiled image from ghcr.io and restart
simplemcp rebuild --verbose                     Show full Docker build output

simplemcp compat claude                         Write kit entries to Claude Desktop config
simplemcp compat lmstudio                       Write kit entries to LM Studio config
simplemcp compat openwebui <url> <api_key>      Register kits with OpenWebUI

simplemcp config list <kit_name>                List config variables for a kit
simplemcp config get <kit_name> <var>           Get a config value
simplemcp config set <kit_name> <var> <val>     Set a config value
simplemcp config reset <kit_name> <var>         Reset a config value to its default

simplemcp browser start                         Start Chrome with CDP + the broker process
simplemcp browser stop                          Stop the Chrome CDP broker
simplemcp browser status                        Show broker and Chrome CDP status
```

## Environment variables and kit config

Kits receive configuration through environment variables. There are two sources:

**Host env forwarding** — The host environment is filtered through an allowlist before being passed into the container. Only variables matching these suffixes are forwarded: `_API_KEY`, `_TOKEN`, `_SECRET`, `_URL`, `_INSTANCE`, `_HOST`, `_PORT`, `_USER`, `_PASSWORD`, `_DB`. Exact matches `TZ`, `LANG`, `LC_ALL` are also forwarded. Everything else (Windows paths, GPU vars, session vars, etc.) is blocked. Any `localhost` or `127.0.0.1` references in forwarded values are rewritten to `host.docker.internal` so kit code can reach host services from inside the container.

**Kit config** — The `config = {"VAR": "default"}` dict in a kit file is stored in `~/.simplemcp/kit_configs/<kit_stem>/config.json` on install and volume-mounted into the container. Manage values with `simplemcp config set/get/list/reset`. These are available as environment variables inside the container and take precedence over host env forwarding.

## Setup

```bash
pip install simplemcp-framework
```

Docker is the only other dependency. On Linux, `simplemcp` will attempt to install Docker automatically if missing and will fix `docker` group permissions with a single `sudo` call if needed.

```bash
simplemcp start
```

The Docker image builds automatically on first start (~2 minutes). Kit dependencies are installed into a persistent volume so subsequent starts are fast. To use the precompiled image instead:

```bash
simplemcp rebuild --pull
```

## Adding a kit

```bash
simplemcp install my_kit.py
```

If the server is already running, the kit is hot-reloaded immediately — no restart needed. Running the same command again on an already-installed kit prints "Updated" and clears the stale bytecode for that kit.

## Client integrations

### Claude Desktop

```bash
simplemcp compat claude
```

Writes a `mcpServers` entry for each installed kit to `claude_desktop_config.json` (path is OS-aware). Each kit gets its own stdio entry pointed at its dedicated port. Removes stale entries for uninstalled kits. Restart Claude Desktop after.

Manual config example:

```json
{
  "mcpServers": {
    "Web Kit V2": {
      "command": "simplemcp",
      "args": ["start", "stdio", "web_kit"]
    },
    "Gotify": {
      "command": "simplemcp",
      "args": ["start", "stdio", "gotify_kit"]
    }
  }
}
```

### LM Studio

```bash
simplemcp compat lmstudio
```

Same format as Claude Desktop, written to `~/.lmstudio/mcp.json`. Restart LM Studio after.

### OpenWebUI

```bash
simplemcp compat openwebui https://your-instance:port sk-your-api-key
```

Hits `POST /api/v1/configs/tool_servers` directly — no manual UI steps. Existing non-SimpleMCP tool server entries are preserved. Generate an API key under your OpenWebUI profile → Settings → Account → API Keys (enable API keys in Admin Panel → Settings → General first).

## Browser automation (Playwright kit)

The Playwright V2 kit connects to Chrome on your host via the Chrome DevTools Protocol (CDP). It doesn't launch its own browser — it drives the one you're already using.

```bash
simplemcp browser start
```

Launches Chrome with `--remote-debugging-port=9222` and starts the broker process that the kit talks to. A socat proxy inside the container forwards `localhost:9222 → host.docker.internal:9222` to work around Chrome's host header validation.

Available tools: `browser_start`, `browser_stop`, `browser_list_tabs`, `browser_open_tab`, `browser_close_tab`, `browser_navigate`, `browser_get_text`, `browser_get_page`, `browser_click`, `browser_fill_and_submit`, `browser_screenshot`, `browser_evaluate`.

Tabs are identified by their CDP target ID (a stable UUID assigned by Chrome). No manual tab registry — `_context.pages` is always the live source of truth.
