Metadata-Version: 2.4
Name: iflow-search-mcp
Version: 0.1.0
Summary: MCP (Model Context Protocol) stdio server for iFlow Search (心流搜索) — exposes web_search, image_search, and web_fetch as MCP tools.
Project-URL: Homepage, https://platform.iflow.cn/
Project-URL: Documentation, https://platform.iflow.cn/docs/
Project-URL: Repository, https://github.com/zhengyanglsun/iflow-search-py
Project-URL: Issues, https://github.com/zhengyanglsun/iflow-search-py/issues
Author: iFlow Search SDK contributors
License: MIT License
        
        Copyright (c) 2026 iFlow Search SDK contributors
        
        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: ai,iflow,llm,mcp,model-context-protocol,search
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
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 :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: iflow-search<0.2,>=0.1.0
Requires-Dist: mcp<2.0,>=1.27
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: types-jsonschema; extra == 'dev'
Description-Content-Type: text/markdown

# iflow-search-mcp

[![PyPI - Version](https://img.shields.io/pypi/v/iflow-search-mcp?include_prereleases)](https://pypi.org/project/iflow-search-mcp/)
[![Python Versions](https://img.shields.io/pypi/pyversions/iflow-search-mcp)](https://pypi.org/project/iflow-search-mcp/)

**MCP stdio server for [iFlow Search](https://platform.iflow.cn/) (心流搜索).**

Exposes three MCP tools backed by the `iflow-search` core SDK:

- `iflow_web_search` — web search
- `iflow_image_search` — image search
- `iflow_web_fetch` — fetch the readable contents of a URL

This package is a thin adapter. All HTTP, authentication, attribution-header
construction, response normalization, and error mapping live in the
[`iflow-search`](https://pypi.org/project/iflow-search/) core SDK. This package
owns only the MCP server wiring — tool definitions, tool dispatch, and the
stdio entry point.

## Install

```bash
pip install iflow-search-mcp
```

> Installing pulls in the MCP Python SDK, which transitively depends on
> `starlette`, `uvicorn`, `sse-starlette`, `python-multipart`,
> `pyjwt[crypto]`, and `jsonschema` — even though this server only uses
> stdio. There is no `[stdio]` extra on the upstream package.

## Configure your MCP host

The server reads its configuration from environment variables only — no
`.env` files, no CLI flags, no config files.

| Variable | Required | Notes |
|---|---|---|
| `IFLOW_API_KEY` | yes | iFlow API key |
| `IFLOW_BASE_URL` | no | Override the platform base URL |
| `IFLOW_TIMEOUT_MS` | no | Request timeout in milliseconds (positive integer) |
| `IFLOW_MCP_CLIENT` | no | Identifier for the MCP host (e.g. `claude-desktop`); regex `^[a-z0-9._-]{1,64}$` |
| `IFLOW_MCP_CLIENT_VERSION` | no | Version of the MCP host; only valid when `IFLOW_MCP_CLIENT` is set |

### Example: Claude Desktop / Claude Code

```jsonc
{
  "mcpServers": {
    "iflow-search": {
      "command": "iflow-search-mcp",
      "env": {
        "IFLOW_API_KEY": "sk-..."
      }
    }
  }
}
```

Claude Code 2.1.148 has been verified to discover and connect to the
`0.1.0a0` artifact via `claude mcp list` / `claude mcp get` (stdio
`initialize` + capability exchange). The wire protocol used by `tools/call`
is exercised separately by the offline `scripts/smoke_stdio.py` and by a
reference-client smoke against the live iFlow API; see
[`docs/design/python-mcp-design.md` §15](https://github.com/zhengyanglsun/iflow-search-py/blob/main/docs/design/python-mcp-design.md#15-claude-code-direct-host-verification--010a0-2026-05-25)
for the full record.

### Example: OpenCode

OpenCode's MCP config schema differs from Claude Desktop's in a few small
ways: the root key is `mcp` (not `mcpServers`), each server declares
`type: "local"` for stdio transport, `command` is a string-array (not a
string), and the env block is named `environment` (not `env`). OpenCode
does **not** expand `${VAR}` references in that block, but it does
inherit the parent process env into the MCP child — so `IFLOW_API_KEY`
belongs in the shell you launch `opencode` from, not in `opencode.json`:

```jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "iflow-search": {
      "type": "local",
      "command": ["iflow-search-mcp"],
      "enabled": true,
      "environment": {
        "IFLOW_MCP_CLIENT": "opencode"
      }
    }
  }
}
```

OpenCode 1.15.10 (installed via `brew install sst/tap/opencode`) has been
verified to discover and connect to the `0.1.0a0` artifact via
`opencode mcp list` — reports `connected · local`, and
`opencode --log-level DEBUG mcp list` records `toolCount=3` and
`successfully created client`. `opencode mcp debug` is documented as an
OAuth debugger for remote MCP servers and is not applicable to
`type: "local"` (stdio) entries; the stdio health check is
`opencode mcp list` itself. The wire protocol used by `tools/call` is
exercised separately by the reference-client smoke against the live
iFlow API; see
[`docs/design/python-mcp-design.md` §16](https://github.com/zhengyanglsun/iflow-search-py/blob/main/docs/design/python-mcp-design.md#16-opencode-direct-host-verification--010a0-2026-05-25)
for the full record.

## Behavior

- **Transport:** stdio only. `stdout` is reserved for the JSON-RPC stream;
  all human-readable output (banner, errors) goes to `stderr`.
- **Exit codes:** `0` on clean shutdown after `SIGINT` / `SIGTERM`,
  `1` on configuration or init error.
- **Errors:** tool failures return `isError: true` results with a stable
  `structuredContent.error.code` (mirroring the core SDK's error contract).

## License

MIT. See [LICENSE](LICENSE).
