microfish 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ name: Publish Docker image
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ contents: read
10
+ packages: write
11
+
12
+ env:
13
+ REGISTRY: ghcr.io
14
+ IMAGE_NAME: ${{ github.repository }}
15
+
16
+ jobs:
17
+ publish:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Validate SemVer tag
23
+ run: |
24
+ if [[ ! "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
25
+ echo "Expected tag format vX.Y.Z or vX.Y.Z-pre.N"
26
+ exit 1
27
+ fi
28
+
29
+ - name: Log in to GHCR
30
+ uses: docker/login-action@v3
31
+ with:
32
+ registry: ${{ env.REGISTRY }}
33
+ username: ${{ github.actor }}
34
+ password: ${{ secrets.GITHUB_TOKEN }}
35
+
36
+ - name: Extract Docker metadata
37
+ id: meta
38
+ uses: docker/metadata-action@v5
39
+ with:
40
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41
+ tags: |
42
+ type=semver,pattern={{version}}
43
+ type=semver,pattern={{major}}.{{minor}}
44
+ type=raw,value=latest
45
+
46
+ - name: Build and push Docker image
47
+ uses: docker/build-push-action@v6
48
+ with:
49
+ context: .
50
+ push: true
51
+ tags: ${{ steps.meta.outputs.tags }}
52
+ labels: ${{ steps.meta.outputs.labels }}
@@ -0,0 +1,45 @@
1
+ name: Publish Python package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: astral-sh/setup-uv@v5
19
+ with:
20
+ enable-cache: true
21
+
22
+ - name: Validate SemVer tag
23
+ run: |
24
+ if [[ ! "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
25
+ echo "Expected tag format vX.Y.Z or vX.Y.Z-pre.N"
26
+ exit 1
27
+ fi
28
+
29
+ - name: Install dependencies
30
+ run: uv sync --frozen
31
+
32
+ - name: Lint
33
+ run: uv run ruff check .
34
+
35
+ - name: Format check
36
+ run: uv run ruff format --check .
37
+
38
+ - name: Test
39
+ run: uv run pytest
40
+
41
+ - name: Build distributions
42
+ run: uv build
43
+
44
+ - name: Publish to PyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,220 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ FROM python:3.11-slim AS runtime
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1
4
+ ENV PYTHONUNBUFFERED=1
5
+
6
+ WORKDIR /app
7
+
8
+ RUN pip install --no-cache-dir uv
9
+
10
+
11
+ COPY pyproject.toml uv.lock ./
12
+ RUN uv sync --frozen --no-dev --no-install-project
13
+
14
+
15
+ COPY src ./src
16
+ COPY README.md README_cn.md ./
17
+ RUN uv sync --frozen --no-dev
18
+
19
+ EXPOSE 8000
20
+
21
+ CMD ["uv", "run", "microfish"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vvtommy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: microfish
3
+ Version: 0.1.0
4
+ Summary: A restricted TinyFish MCP gateway for free search and fetch capabilities.
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: httpx<1,>=0.27
8
+ Requires-Dist: mcp<2,>=1.12
9
+ Requires-Dist: pydantic-settings<3,>=2.4
10
+ Requires-Dist: pydantic<3,>=2.8
11
+ Requires-Dist: starlette<1,>=0.37
12
+ Requires-Dist: uvicorn[standard]<1,>=0.30
13
+ Description-Content-Type: text/markdown
14
+
15
+ <img src=".github/assets/microfish-logo.png" width="128" vertical-align="middle">
16
+
17
+ # microfish
18
+
19
+ 中文文档: [README_cn.md](README_cn.md)
20
+
21
+ microfish is a restricted TinyFish MCP gateway. It exposes only the allowlisted TinyFish Search and Fetch related tools.
22
+
23
+ ## Tools
24
+
25
+ Retained tools:
26
+ - search
27
+ - fetch_content
28
+ - get_search_usage
29
+ - list_fetch_usage
30
+
31
+ Blocked tool groups:
32
+ - Agent automation
33
+ - Batch automation
34
+ - Browser sessions
35
+
36
+ ## Authentication and running modes
37
+
38
+ microfish only exposes TinyFish Search and Fetch related APIs. TinyFish Agent, Browser, batch, and run lifecycle APIs are intentionally not registered.
39
+
40
+ ### Get a TinyFish API key
41
+
42
+ Generate your API key at https://agent.tinyfish.ai/api-keys.
43
+
44
+ ### Client-owned single key
45
+
46
+ Leave `TINYFISH_KEYS` unset. Each MCP client sends `Authorization: Bearer <YOUR_TINYFISH_API_KEY>`. microfish forwards that value to TinyFish as `X-API-Key` for the current request only.
47
+
48
+ ### Server-managed single key
49
+
50
+ Set `TINYFISH_KEYS` to one TinyFish API key. MCP clients do not receive the TinyFish key. If `MCP_AUTH_TOKEN` is set, clients send `Authorization: Bearer <YOUR_MCP_AUTH_TOKEN>`; if `MCP_AUTH_TOKEN` is unset, the MCP entrypoint is not protected by a bearer token.
51
+
52
+ ### Server-managed key pool
53
+
54
+ Set `TINYFISH_KEYS` to multiple comma-separated TinyFish API keys. microfish assigns requests in order. When a whole upstream request fails, it tries the next key, stopping after all available keys for that call are tried or after three extra retries.
55
+
56
+ ## Server configuration
57
+
58
+ microfish reads runtime settings from environment variables:
59
+
60
+ - `MICROFISH_HOST`: bind host for the HTTP server. Defaults to `0.0.0.0`.
61
+ - `MICROFISH_PORT`: bind port for the HTTP server. Defaults to `8000`.
62
+ - `MICROFISH_MCP_PATH`: HTTP path that exposes the MCP entrypoint. Defaults to `/mcp`.
63
+ - `MICROFISH_TRANSPORT`: transport for the server. Use http for the HTTP service or stdio for local coding agent subprocesses. Defaults to http.
64
+ - `TINYFISH_KEYS`: comma-separated TinyFish API keys; presence selects server-managed mode.
65
+ - `MCP_AUTH_TOKEN`: optional bearer token required from MCP clients in server-managed mode.
66
+
67
+ ## Client configuration
68
+
69
+ microfish supports two transports:
70
+ - **HTTP transport** (`MICROFISH_TRANSPORT=http`, the default): run microfish as an HTTP service and connect clients to `http://localhost:8000/mcp`.
71
+ - **stdio transport** (`MICROFISH_TRANSPORT=stdio` or `--transport stdio`): launch `uvx microfish --transport stdio` as a local subprocess for coding agents.
72
+
73
+ For the HTTP transport, the value of `Authorization: Bearer` depends on your running mode:
74
+ - **Client-owned single key**: set it to your TinyFish API key.
75
+ - **Server-managed single/multiple keys with `MCP_AUTH_TOKEN`**: set it to the MCP auth token.
76
+ - **Server-managed keys without `MCP_AUTH_TOKEN`**: omit the Authorization header entirely.
77
+
78
+ The stdio transport requires `TINYFISH_KEYS` because there is no separate Authorization header on local subprocess pipes.
79
+
80
+ ### Claude Code
81
+
82
+ HTTP transport:
83
+
84
+ ```bash
85
+ # Without auth header
86
+ claude mcp add --transport http microfish http://localhost:8000/mcp
87
+
88
+ # With auth header
89
+ claude mcp add --transport http microfish http://localhost:8000/mcp \
90
+ --header "Authorization: Bearer <YOUR_MCP_OR_TINYFISH_TOKEN>"
91
+ ```
92
+
93
+ stdio transport:
94
+
95
+ ```bash
96
+ TINYFISH_KEYS=<YOUR_TINYFISH_API_KEY> \
97
+ claude mcp add microfish --env TINYFISH_KEYS -- uvx microfish --transport stdio
98
+ ```
99
+
100
+ ### Codex
101
+
102
+ HTTP transport:
103
+
104
+ ```toml
105
+ [mcp_servers.microfish]
106
+ url = "http://localhost:8000/mcp"
107
+ bearer_token_env_var = "MICROFISH_MCP_BEARER"
108
+ ```
109
+
110
+ Set `MICROFISH_MCP_BEARER` in your shell environment to your TinyFish API key (client-owned mode) or MCP auth token (server-managed mode).
111
+
112
+ stdio transport:
113
+
114
+ ```toml
115
+ [mcp_servers.microfish]
116
+ command = "uvx"
117
+ args = ["microfish", "--transport", "stdio"]
118
+ env = { TINYFISH_KEYS = "<YOUR_TINYFISH_API_KEY>" }
119
+ ```
120
+
121
+ ### Cursor
122
+
123
+ HTTP transport:
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "microfish": {
129
+ "url": "http://localhost:8000/mcp",
130
+ "headers": {
131
+ "Authorization": "Bearer ${env:MICROFISH_MCP_BEARER}"
132
+ }
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ Set `MICROFISH_MCP_BEARER` in your environment to your TinyFish API key (client-owned mode) or MCP auth token (server-managed mode). If no auth token is required, remove the `headers` block.
139
+
140
+ stdio transport:
141
+
142
+ ```json
143
+ {
144
+ "mcpServers": {
145
+ "microfish": {
146
+ "command": "uvx",
147
+ "args": ["microfish", "--transport", "stdio"],
148
+ "env": {
149
+ "TINYFISH_KEYS": "<YOUR_TINYFISH_API_KEY>"
150
+ }
151
+ }
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## Run locally
157
+
158
+ uv sync
159
+ uv run microfish
160
+
161
+ Or run directly without cloning via `uvx microfish`.
162
+
163
+ ## Docker
164
+
165
+ Two compose files are provided:
166
+ - `docker-compose.yml` pulls the published image `ghcr.io/vvtommy/microfish:${MICROFISH_IMAGE_TAG:-latest}` from GHCR.
167
+ - `docker-compose_build.yml` builds the local Dockerfile.
168
+
169
+ Both expose microfish on port 8000. Do not put TinyFish keys directly in compose files; pass them through your deployment environment.
170
+
171
+ ```bash
172
+ docker compose up -d
173
+ claude mcp add --transport http microfish http://localhost:8000/mcp \
174
+ --header "Authorization: Bearer <YOUR_MCP_OR_TINYFISH_TOKEN>"
175
+ ```
176
+
177
+ ## Releasing
178
+
179
+ Push a SemVer tag of the form `vX.Y.Z` to trigger publish workflows:
180
+ - `.github/workflows/pypi.yml` builds and publishes the Python package to PyPI via PyPI OIDC trusted publishing.
181
+ - `.github/workflows/docker.yml` builds and publishes `ghcr.io/vvtommy/microfish` Docker images with version tags and `latest`.
182
+
183
+ ## MCP endpoint
184
+
185
+ http://localhost:8000/mcp