deapi-mcp 0.7.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.
Files changed (35) hide show
  1. deapi_mcp-0.7.0/.gitignore +90 -0
  2. deapi_mcp-0.7.0/CHANGELOG.md +206 -0
  3. deapi_mcp-0.7.0/LICENSE +21 -0
  4. deapi_mcp-0.7.0/PKG-INFO +642 -0
  5. deapi_mcp-0.7.0/README.md +596 -0
  6. deapi_mcp-0.7.0/SECURITY.md +37 -0
  7. deapi_mcp-0.7.0/deapi_mcp/__init__.py +24 -0
  8. deapi_mcp-0.7.0/deapi_mcp/auth.py +33 -0
  9. deapi_mcp-0.7.0/deapi_mcp/auth_code_store.py +226 -0
  10. deapi_mcp-0.7.0/deapi_mcp/config.py +297 -0
  11. deapi_mcp-0.7.0/deapi_mcp/consent.py +549 -0
  12. deapi_mcp-0.7.0/deapi_mcp/deapi_client.py +466 -0
  13. deapi_mcp-0.7.0/deapi_mcp/fastmcp_auth.py +227 -0
  14. deapi_mcp-0.7.0/deapi_mcp/key_verifier.py +225 -0
  15. deapi_mcp-0.7.0/deapi_mcp/landing.py +431 -0
  16. deapi_mcp-0.7.0/deapi_mcp/middleware.py +756 -0
  17. deapi_mcp-0.7.0/deapi_mcp/oauth_clients.py +443 -0
  18. deapi_mcp-0.7.0/deapi_mcp/oauth_endpoints.py +973 -0
  19. deapi_mcp-0.7.0/deapi_mcp/observability.py +199 -0
  20. deapi_mcp-0.7.0/deapi_mcp/polling_manager.py +319 -0
  21. deapi_mcp-0.7.0/deapi_mcp/py.typed +0 -0
  22. deapi_mcp-0.7.0/deapi_mcp/schemas.py +397 -0
  23. deapi_mcp-0.7.0/deapi_mcp/server_remote.py +416 -0
  24. deapi_mcp-0.7.0/deapi_mcp/tools/__init__.py +0 -0
  25. deapi_mcp-0.7.0/deapi_mcp/tools/_price_helpers.py +167 -0
  26. deapi_mcp-0.7.0/deapi_mcp/tools/_responses.py +157 -0
  27. deapi_mcp-0.7.0/deapi_mcp/tools/audio.py +1195 -0
  28. deapi_mcp-0.7.0/deapi_mcp/tools/embedding.py +102 -0
  29. deapi_mcp-0.7.0/deapi_mcp/tools/image.py +884 -0
  30. deapi_mcp-0.7.0/deapi_mcp/tools/prompt.py +155 -0
  31. deapi_mcp-0.7.0/deapi_mcp/tools/utility.py +230 -0
  32. deapi_mcp-0.7.0/deapi_mcp/tools/video.py +1117 -0
  33. deapi_mcp-0.7.0/deapi_mcp/utils.py +666 -0
  34. deapi_mcp-0.7.0/deapi_mcp/webhooks.py +349 -0
  35. deapi_mcp-0.7.0/pyproject.toml +106 -0
@@ -0,0 +1,90 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+
8
+ # Virtual environments
9
+ env/
10
+ venv/
11
+ ENV/
12
+ env.bak/
13
+ venv.bak/
14
+ .venv
15
+ .venv*/
16
+
17
+ # Distribution / packaging
18
+ dist/
19
+ build/
20
+ *.egg-info/
21
+ .eggs/
22
+ *.egg
23
+
24
+ # PyInstaller
25
+ *.manifest
26
+ *.spec
27
+
28
+ # Testing
29
+ .pytest_cache/
30
+ .coverage
31
+ .coverage.*
32
+ htmlcov/
33
+ .tox/
34
+ .nox/
35
+ coverage.xml
36
+ *.cover
37
+ .hypothesis/
38
+
39
+ # IDE
40
+ .vscode/
41
+ .idea/
42
+ *.swp
43
+ *.swo
44
+ *~
45
+ .DS_Store
46
+ Thumbs.db
47
+
48
+ # Environment variables
49
+ .env
50
+ .env.*
51
+ !.env.example
52
+
53
+ # Logs
54
+ *.log
55
+ logs/
56
+
57
+ # Database
58
+ *.db
59
+ *.sqlite
60
+ *.sqlite3
61
+
62
+ # Jupyter Notebook
63
+ .ipynb_checkpoints
64
+
65
+ # mypy
66
+ .mypy_cache/
67
+ .dmypy.json
68
+ dmypy.json
69
+
70
+ # Pyre type checker
71
+ .pyre/
72
+
73
+ # pytype static type analyzer
74
+ .pytype/
75
+
76
+ # Rope project settings
77
+ .ropeproject
78
+
79
+ # mkdocs documentation
80
+ /site
81
+
82
+ # MCP config (contains tokens)
83
+ .mcp.json
84
+
85
+ # Project specific
86
+ *.bak
87
+ *.backup
88
+
89
+ # Claude Code local settings
90
+ .claude/
@@ -0,0 +1,206 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project. Versions follow [Semantic Versioning](https://semver.org/);
4
+ releases are git tags `vX.Y.Z`.
5
+
6
+ ## 0.7.0
7
+
8
+ ### Added
9
+ - A plain deAPI API key is checked against the API before it is accepted
10
+ (`deapi_mcp/key_verifier.py`). Until now any string that was not a JWT passed as a bearer
11
+ token: `initialize` and `tools/list` succeeded and every tool call then failed with
12
+ `success: false` and "Unauthenticated.", which gave a client no reason to ask the user for
13
+ a new key. Now:
14
+ - `Authorization: Bearer <key>` with a key the API refuses gets `401`
15
+ (`WWW-Authenticate: Bearer error="invalid_token"`), already at `initialize`;
16
+ - `POST /token` answers `401 invalid_client` when the `client_secret` (the key) is refused,
17
+ for both the `authorization_code` and `client_credentials` grants.
18
+
19
+ The check is one free `GET /api/v2/account/balance` with the key. The verdict is cached
20
+ under an HMAC of the key (accepted 10 minutes, refused 60 seconds, at most 10,000 keys) and
21
+ concurrent requests with one key share a single check. Only a `401` refuses a key: when the
22
+ API is down, slow (5-second limit) or rate-limiting, the key is let through as before. JWTs,
23
+ refresh tokens and the OAuth flow with a valid key are unchanged.
24
+ - `DEAPI_VERIFY_API_KEYS` (default `true`) turns the check off.
25
+ - Authentication failures report the new reason `invalid_key` to the auth-rejected sink
26
+ (`observability.set_auth_rejected_sink`).
27
+ - The key is also accepted in an `X-API-Key` header, for clients that let a user set one named
28
+ header. It goes through the same checks as `Authorization: Bearer`, which wins when a request
29
+ carries both. A key in the URL is still never read.
30
+ - `GET /` serves a setup page: the endpoint, where to get a key, a section per client (Claude,
31
+ ChatGPT, Claude Code, Cursor, VS Code, Codex CLI, Gemini CLI, any other client), a way to check the
32
+ connection and the tool list, generated from the server's own registry. One static document
33
+ with no script and no external resource, under a strict Content-Security-Policy. It follows
34
+ the deapi.ai look (dark, amber accents, the deAPI logo inline as SVG).
35
+
36
+ - OAuth for clients that register themselves: hosted connectors and apps no longer need a
37
+ Client ID and Secret typed in by hand.
38
+ - `POST /register` (RFC 7591 dynamic client registration) for public clients. The returned
39
+ `client_id` is the registration itself, signed with a key derived from
40
+ `DEAPI_JWT_SECRET_KEY`, so nothing is stored and any replica can verify it.
41
+ - Client ID Metadata Documents: an `https` `client_id` is fetched (public addresses only, no
42
+ redirects, 5 kB, cached 5 minutes) and its `redirect_uris` and name are used.
43
+ - A deAPI sign-in screen at `/authorize` for these clients: it names the application and
44
+ where the browser will return, warns about unverified applications and apps on this
45
+ computer, and asks for an API key, which is checked with deAPI before a code is issued.
46
+ Signed authorization request, CSRF cookie, a limit on wrong keys per client IP (shared
47
+ through Redis), no script, no framing, nothing cached.
48
+ - Public clients use PKCE without a secret; their codes and refresh tokens are bound to the
49
+ `client_id` they were issued to. Redirect URIs must match a registered one exactly
50
+ (loopback `http` on any port, RFC 8252).
51
+ - Authorization responses carry `iss` (RFC 9207), and a `resource` (RFC 8707) that names
52
+ another server is refused with `invalid_target`.
53
+ - `DEAPI_OAUTH_PUBLIC_CLIENTS` (default `true`) turns all of this off.
54
+ - `DEAPI_CLIENT_IP_HEADER` names a header with the real client address from a trusted edge
55
+ (e.g. `CF-Connecting-IP`), for the wrong-key limit.
56
+ - A `401` from deAPI on a real call (a key revoked or deleted after sign-in) ends the session:
57
+ the client's next request is refused with `401 invalid_token`, its refresh with
58
+ `invalid_grant`, so it signs in again. The tool result says what happened.
59
+
60
+ ### Changed
61
+ - Published on PyPI as `deapi-mcp` (`pip install deapi-mcp`, `uvx deapi-mcp`). A GitHub Release
62
+ (tag `vX.Y.Z`) builds and uploads it with PyPI trusted publishing; the sdist ships only the
63
+ package and its docs.
64
+ - The deAPI SDK comes from PyPI (`deapi-sdk>=0.6.1,<0.7`) instead of a GitHub tag tarball.
65
+ - A `401 invalid_token` on `/mcp` now says how to fix it: check the deAPI API key, or sign in
66
+ again with OAuth. FastMCP's own text told clients to re-register, which this server does not
67
+ support. Status, error code and `resource_metadata` are unchanged.
68
+ - OAuth stays a pre-registered client (`client_id=deapi-mcp`, the API key as `client_secret`),
69
+ now tightened where it fell short of the spec:
70
+ - `POST /token` accepts `client_secret_basic`, which the metadata already advertised but the
71
+ endpoint ignored. A failed Basic authentication gets the `WWW-Authenticate: Basic` challenge.
72
+ - Every `/token` answer carries `Cache-Control: no-store` (RFC 6749 §5.1).
73
+ - A refresh whose key deAPI now refuses (revoked or rotated) gets `invalid_grant`, so the
74
+ client signs in again instead of minting access tokens no tool call can use. An API outage
75
+ still lets the refresh through.
76
+ - `/authorize` accepts Cursor's documented callback `cursor://anysphere.cursor-mcp/oauth/callback`
77
+ as an exact string (RFC 8252 private-use scheme); any other non-http(s) callback is refused
78
+ as before.
79
+ - `/authorize` checks that `code_challenge` is a well-formed S256 value (43 base64url
80
+ characters), not only that one is present.
81
+ - `service_documentation` in the authorization server metadata points to the MCP server docs.
82
+
83
+ Nothing is removed: tokens issued by 0.6.x stay valid, and the `deapi-mcp` flow works as
84
+ before (no sign-in screen).
85
+
86
+ ### Fixed
87
+ - README: Claude Desktop takes remote servers from Connectors; the `claude_desktop_config.json`
88
+ example with a URL and headers, which Claude Desktop does not read for remote servers, is gone.
89
+
90
+ ## 0.6.3
91
+
92
+ ### Fixed
93
+ - The links to the deAPI API key page (README, `AUTH.md` and the `server.json` key description
94
+ shown in the MCP Registry) pointed to a page that does not exist. They now go to
95
+ https://app.deapi.ai/settings/api-keys.
96
+
97
+ ## 0.6.2
98
+
99
+ ### Changed
100
+ - Every transcription tool and its price tool (`audio_transcription`, `audio_url_transcription`,
101
+ `video_file_transcription`, `video_url_transcription`) defaults to `WhisperLargeV3Ct2` instead
102
+ of `WhisperLargeV3`. WhisperLargeV3 ignores `lang`; Ct2 costs the same, honours `lang`,
103
+ returns segments and supports `diarize` and word timestamps.
104
+ - `lang` now tells the agent to set it whenever the language is known (auto-detection can pick
105
+ the wrong one) and warns that it forces the output language, so a wrong code returns a
106
+ translation instead of a transcript.
107
+ - `server.json`: the API key placeholder shows the current format `sk-dp-<id>-<secret>`
108
+ (`<id>|<secret>` keys keep working), and the description fits the registry's 100-character
109
+ limit and names video description and music.
110
+ - README lists TikTok among the `video_url_transcription` sources.
111
+
112
+ ## 0.6.1
113
+
114
+ ### Fixed
115
+ - A tool call whose wait ran to the end of its budget gave up without reading the job status
116
+ again. With completion webhooks on and a callback that never arrived, the wait on that callback
117
+ could take the whole budget, so a job that had long finished came back as still running
118
+ (`done: false`). The last wait is now always followed by one more status read.
119
+
120
+ ### Changed
121
+ - `DEAPI_WEBHOOK_FALLBACK_POLL_INTERVAL` defaults to 15 s (was 45 s, the same as
122
+ `DEAPI_TOOL_MAX_WAIT`). A callback that does not arrive now costs at most about 15 s.
123
+
124
+ ## 0.6.0
125
+
126
+ ### Added
127
+ - Pluggable job registry for completion webhooks: `create_app(server, job_registry=...)` takes any
128
+ implementation of `deapi_mcp.webhooks.JobRegistry`, so replicas that share one receiver URL can
129
+ relay callbacks to each other. Its `start`/`stop` run with the app's lifespan while webhooks
130
+ are on. The default stays in process memory.
131
+ - Webhook deliveries are deduplicated on `delivery_id`: a replayed delivery is acknowledged and
132
+ wakes nobody.
133
+
134
+ ### Changed
135
+ - `JobCompletionRegistry.signal` is a coroutine; the synchronous local wake-up is `wake`.
136
+ - The module-level `deapi_mcp.webhooks.registry` is gone: use `get_job_registry()` /
137
+ `set_job_registry()`.
138
+ - The receiver answers `400` when `job_request_id` is not a non-empty string. A registry failure
139
+ is logged and the callback acknowledged; the job completes on the fallback poll.
140
+
141
+ ## 0.5.2
142
+
143
+ ### Added
144
+ - `deapi_mcp.__version__`. The server reports its version in the MCP `serverInfo`.
145
+ - `py.typed`: type checkers now use the package's annotations.
146
+ - `CHANGELOG.md` and `SECURITY.md` (how to report a vulnerability privately).
147
+
148
+ ### Changed
149
+ - Default Redis databases are now `0` for OAuth codes (`DEAPI_REDIS_DB`) and `1` for a metrics
150
+ overlay (`DEAPI_METRICS_REDIS_DB`). If you relied on the previous defaults, set both explicitly.
151
+
152
+ ### Removed
153
+ - The `DEAPI_RETRY_BACKOFF_FACTOR` setting. Nothing read it since retries moved to the deAPI SDK.
154
+ An existing value is ignored.
155
+
156
+ ### Docs
157
+ - `.env.example` lists the embedding and default polling settings and the settings an optional
158
+ metrics overlay can use (`DEAPI_METRICS_*`).
159
+ - README: polling table covers every job type; `PUBLIC_BASE_URL` and `FORWARDED_ALLOW_IPS` in
160
+ the configuration block.
161
+ - DEPLOYMENT.md: set `PUBLIC_BASE_URL` behind a reverse proxy, or OAuth discovery fails.
162
+
163
+ ## 0.5.1
164
+
165
+ ### Changed
166
+ - Polling status is sent as MCP progress notifications instead of log notifications.
167
+ - A blank `DEAPI_*` value means the default.
168
+ - deapi-sdk 0.5.2.
169
+
170
+ ### Fixed
171
+ - `/token` answers `503` with `Retry-After` when the code store is unreachable.
172
+ - The authorization code store takes the time from Redis, not from the application clock.
173
+ - The code index TTL can only grow.
174
+ - A corrupt stored code counts as an unknown code (`invalid_grant`) instead of a `500`.
175
+ - A call's outcome is labelled by the note that ended it. Tolerated catalogue errors and retried
176
+ status errors no longer change it.
177
+
178
+ ## 0.5.0
179
+
180
+ ### Breaking
181
+ - The import package is `deapi_mcp` (was `src`). Run the server with
182
+ `python -m deapi_mcp.server_remote`.
183
+ - Python 3.11 is the minimum.
184
+ - `video_replace` and `video_remove_background` (and their price tools) are removed. The API no
185
+ longer offers them.
186
+
187
+ ### Added
188
+ - HTTP goes through the deAPI SDK over one shared connection pool. A job submission is retried
189
+ only when it provably was not processed, so a job is never submitted twice.
190
+ - Importable server: `register_core_tools(server)`, `create_app(server, *, metrics=None)` and
191
+ `build_app()`. A deployment can inject its own metrics overlay.
192
+ - Optional Redis store for OAuth authorization codes, so several replicas can serve one login.
193
+ - Optional completion webhooks (`DEAPI_WEBHOOKS_INTERNAL`) wake the poller.
194
+ - Graceful drain of in-flight tool calls on SIGTERM (`MCP_GRACEFUL_SHUTDOWN_SECONDS`).
195
+ - `video_description` and `video_description_price`.
196
+ - mypy `--strict` and GitHub Actions CI (ruff, black, mypy, pytest on Python 3.11-3.14).
197
+
198
+ ### Fixed
199
+ - `/token` answered `500` when a form field was sent as a multipart file part. It now answers
200
+ `400`/`401`.
201
+ - The model catalogue treated "never fetched" as fresh on a host up for less than the cache TTL.
202
+
203
+ ## Before 0.5.0
204
+
205
+ Untagged releases from February to May 2026: the initial server, deAPI API v2, music,
206
+ audio-to-video, video upscale, prompt boosters and MCP registry metadata.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 deAPI Team
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.