gitcode-api 1.2.21__tar.gz → 1.3.1__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 (75) hide show
  1. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/PKG-INFO +15 -18
  2. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/README.md +12 -15
  3. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/__init__.py +8 -2
  4. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_exceptions.py +2 -0
  5. gitcode_api-1.3.1/gitcode_api/exceptions.py +19 -0
  6. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/llm/mcp.py +6 -6
  7. gitcode_api-1.3.1/gitcode_api/models.py +205 -0
  8. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/resources/__init__.py +1 -1
  9. gitcode_api-1.3.1/gitcode_api/resources/_shared/__init__.py +18 -0
  10. gitcode_api-1.3.1/gitcode_api/resources/_shared/base.py +129 -0
  11. gitcode_api-1.2.21/gitcode_api/resources/_shared.py → gitcode_api-1.3.1/gitcode_api/resources/_shared/fetch_template.py +133 -259
  12. gitcode_api-1.3.1/gitcode_api/resources/account/__init__.py +17 -0
  13. gitcode_api-1.3.1/gitcode_api/resources/account/oauth_resource_group.py +159 -0
  14. gitcode_api-1.3.1/gitcode_api/resources/account/orgs_resource_group.py +422 -0
  15. gitcode_api-1.3.1/gitcode_api/resources/account/search_resource_group.py +236 -0
  16. gitcode_api-1.3.1/gitcode_api/resources/account/users_resource_group.py +249 -0
  17. gitcode_api-1.3.1/gitcode_api/resources/collaboration/__init__.py +20 -0
  18. gitcode_api-1.3.1/gitcode_api/resources/collaboration/_helpers.py +10 -0
  19. gitcode_api-1.3.1/gitcode_api/resources/collaboration/issues_resource_group.py +866 -0
  20. gitcode_api-1.3.1/gitcode_api/resources/collaboration/labels_resource_group.py +248 -0
  21. gitcode_api-1.3.1/gitcode_api/resources/collaboration/members_resource_group.py +195 -0
  22. gitcode_api-1.3.1/gitcode_api/resources/collaboration/milestones_resource_group.py +192 -0
  23. gitcode_api-1.3.1/gitcode_api/resources/collaboration/pulls_resource_group.py +1300 -0
  24. gitcode_api-1.3.1/gitcode_api/resources/misc/__init__.py +14 -0
  25. gitcode_api-1.3.1/gitcode_api/resources/misc/releases_resource_group.py +445 -0
  26. gitcode_api-1.3.1/gitcode_api/resources/misc/tags_resource_group.py +286 -0
  27. gitcode_api-1.3.1/gitcode_api/resources/misc/webhooks_resource_group.py +192 -0
  28. gitcode_api-1.3.1/gitcode_api/resources/repositories/__init__.py +17 -0
  29. gitcode_api-1.3.1/gitcode_api/resources/repositories/branches_resource_group.py +151 -0
  30. gitcode_api-1.3.1/gitcode_api/resources/repositories/commits_resource_group.py +333 -0
  31. gitcode_api-1.3.1/gitcode_api/resources/repositories/repo_contents_resource_group.py +459 -0
  32. gitcode_api-1.3.1/gitcode_api/resources/repositories/repos_resource_group.py +1279 -0
  33. gitcode_api-1.3.1/gitcode_api/version.txt +1 -0
  34. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api.egg-info/PKG-INFO +15 -18
  35. gitcode_api-1.3.1/gitcode_api.egg-info/SOURCES.txt +67 -0
  36. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/pyproject.toml +29 -18
  37. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_resources_account.py +2 -3
  38. gitcode_api-1.2.21/gitcode_api/resources/account.py +0 -1086
  39. gitcode_api-1.2.21/gitcode_api/resources/collaboration.py +0 -2818
  40. gitcode_api-1.2.21/gitcode_api/resources/misc.py +0 -901
  41. gitcode_api-1.2.21/gitcode_api/resources/repositories.py +0 -2197
  42. gitcode_api-1.2.21/gitcode_api/version.txt +0 -1
  43. gitcode_api-1.2.21/gitcode_api.egg-info/SOURCES.txt +0 -46
  44. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/LICENSE +0 -0
  45. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/__main__.py +0 -0
  46. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_base_client.py +0 -0
  47. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_base_resource.py +0 -0
  48. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_cli_banner.py +0 -0
  49. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_client.py +0 -0
  50. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/_models.py +0 -0
  51. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/cli.py +0 -0
  52. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/constants.py +0 -0
  53. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/llm/__init__.py +0 -0
  54. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/llm/_tool.py +0 -0
  55. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/llm/jiuwen.py +0 -0
  56. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/llm/openai.py +0 -0
  57. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/py.typed +0 -0
  58. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/run_mcp.py +0 -0
  59. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api/utils.py +0 -0
  60. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api.egg-info/dependency_links.txt +0 -0
  61. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api.egg-info/entry_points.txt +0 -0
  62. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api.egg-info/requires.txt +0 -0
  63. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/gitcode_api.egg-info/top_level.txt +0 -0
  64. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/setup.cfg +0 -0
  65. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_base_client.py +0 -0
  66. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_build_manifest.py +0 -0
  67. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_cli.py +0 -0
  68. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_client.py +0 -0
  69. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_collaboration_templates.py +0 -0
  70. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_llm_tools.py +0 -0
  71. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_models.py +0 -0
  72. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_resources_collaboration.py +0 -0
  73. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_resources_misc.py +0 -0
  74. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_resources_repositories.py +0 -0
  75. {gitcode_api-1.2.21 → gitcode_api-1.3.1}/tests/test_utils.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-api
3
- Version: 1.2.21
3
+ Version: 1.3.1
4
4
  Summary: Easy to use Python SDK for the GitCode REST API. Providing builtin CLI tool, and optional LLM integration (MCP, OpenAI tool, and openJiuwen tool) for agents. Community-maintained.
5
- Author-email: Hugo Huang <hugo@hugohuang.com>
5
+ Author-email: "Hugo (Jin Huang)" <hugo@hugohuang.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Changelog, https://gitcode-api.readthedocs.io/en/latest/changelog.html
8
8
  Project-URL: Issues, https://github.com/Trenza1ore/GitCode-API/issues
@@ -12,7 +12,7 @@ Project-URL: Github, https://github.com/Trenza1ore/GitCode-API
12
12
  Project-URL: Homepage, https://hugohuang.com/gitcode-api
13
13
  Project-URL: Author, https://hugohuang.com
14
14
  Keywords: gitcode,git,devops,api,sdk,python,httpx,client,mcp,agent,fastmcp,llm,openjiuwen,mcp client,mcp server,model context protocol
15
- Classifier: Development Status :: 4 - Beta
15
+ Classifier: Development Status :: 5 - Production/Stable
16
16
  Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: Implementation :: CPython
18
18
  Classifier: Programming Language :: Python :: 3
@@ -35,15 +35,12 @@ Provides-Extra: mcp
35
35
  Requires-Dist: fastmcp; python_version >= "3.10" and extra == "mcp"
36
36
  Dynamic: license-file
37
37
 
38
- # GitCode-API
39
-
40
- [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F&uuid=c9611358e1474a759d09ac0b861d8d22)](https://pypi.org/project/gitcode-api) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/gitcode-api?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=downloads&uuid=c9611358e1474a759d09ac0b861d8d22)](https://pepy.tech/projects/gitcode-api)
41
- [![Install in Cursor](https://img.shields.io/badge/Install_in-Cursor-000000?logoColor=white)](https://cursor.com/en/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19) [![Install in VS Code](https://img.shields.io/badge/Install_in-VS_Code-0098FF?logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=GitCode%20API&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22--from%22%2C%22gitcode-api%5Bmcp%5D%22%2C%22gitcode-api%22%2C%22serve%22%5D%2C%22env%22%3A%7B%22GITCODE_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agitcode_access_token%7D%22%7D%2C%22inputs%22%3A%5B%7B%22id%22%3A%22gitcode_access_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Enter%20GITCODE_ACCESS_TOKEN%22%2C%22password%22%3Atrue%7D%5D%7D)
42
- [![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API)](https://github.com/Trenza1ore/GitCode-API) [![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API)](https://gitcode.com/SushiNinja/GitCode-API) [![CI Badge](https://github.com/Trenza1ore/GitCode-API/actions/workflows/check-code.yml/badge.svg?uuid=c9611358e1474a759d09ac0b861d8d22)](https://github.com/Trenza1ore/GitCode-API/actions/workflows/check-code.yml/)
38
+ # GitCode-API [![GitCode Badge](https://img.shields.io/badge/gitcode-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API)](https://gitcode.com/SushiNinja/GitCode-API) [![GitHub Badge](https://img.shields.io/badge/github-black?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API)](https://github.com/Trenza1ore/GitCode-API)
39
+ [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?color=blue&uuid=96abf98469db4ee7bc12ded4646e76d9)](https://pypi.org/project/gitcode-api) [![PyPI - Downloads](https://img.shields.io/pypi/dm/gitcode-api?color=blue&logo=pypi&logoColor=white&label=PyPI%20%E2%86%93&uuid=96abf98469db4ee7bc12ded4646e76d9)](https://pepy.tech/projects/gitcode-api) ![MCP Bundle Downloads](https://img.shields.io/github/downloads/Trenza1ore/GitCode-API/total?color=blue&logo=modelcontextprotocol&label=MCPB%20%E2%86%93&uuid=96abf98469db4ee7bc12ded4646e76d9)
43
40
 
44
41
  [![Docs](https://img.shields.io/badge/%E6%96%87%E6%A1%A3-Docs-cyan?style=for-the-badge&logo=readthedocs&link=https%3A%2F%2Fgitcode-api.readthedocs.io%2Fen%2Flatest%2Findex.html)](https://gitcode-api.readthedocs.io) [![中文README](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-README-brown?style=for-the-badge&logo=googledocs&link=README.zh.md)](README.zh.md)
45
42
 
46
- `gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, repository-scoped helpers, and lightweight response models so you can work with GitCode from Python without hand-writing raw HTTP requests. The `gitcode_api.llm` module adds an OpenAI-style function tool, an MCP service, and an [openJiuwen](https://openjiuwen.com) tool integration so agents can reuse the same resource-oriented API.
43
+ `gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, helpers methods grouped by resource groups, and type-hinted response models so you can work with GitCode from Python without hand-writing raw HTTP requests. The `gitcode_api.llm` module adds an OpenAI-style function tool, an MCP service, and an [openJiuwen](https://openjiuwen.com) tool integration so agents can reuse the same resource-oriented API.
47
44
 
48
45
  ## Why This Project
49
46
 
@@ -51,7 +48,7 @@ Dynamic: license-file
51
48
  - Sync and async clients with a consistent API surface.
52
49
  - Convenient methods not offered by REST API directly: such as fetching Issue and PR templates.
53
50
  - Resource groups such as `client.repos`, `client.pulls`, and `client.users`.
54
- - Repository defaults via `owner=` and `repo=` on the client.
51
+ - Repository defaults via `owner` and `repo` on the client.
55
52
  - Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
56
53
  - Provides MCP server, OpenAI tool, and [openJiuwen](https://openjiuwen.com) tool for LLM agent usage.
57
54
  - Provide MCP service that directly installs to your IDE of choice, such as Cursor and VS Code!
@@ -77,14 +74,14 @@ For detailed setup (including installing to services like Claude Code / Codex):
77
74
 
78
75
  ## Authentication
79
76
 
80
- Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
77
+ Pass `api_key` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
81
78
 
82
79
  ```bash
83
80
  export GITCODE_ACCESS_TOKEN="your-token"
84
81
  ```
85
82
 
86
- If your token is stored in encrypted form, pass `decrypt=` to decode either an
87
- encrypted `api_key=` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
83
+ If your token is stored in encrypted form, pass `decrypt` to decode either an
84
+ encrypted `api_key` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
88
85
  the client uses it.
89
86
 
90
87
  ```python
@@ -171,7 +168,7 @@ meta = as_dict(repo) # dict
171
168
 
172
169
  ### Context managers
173
170
 
174
- `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
171
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
175
172
 
176
173
  ```python
177
174
  from gitcode_api import GitCode
@@ -328,7 +325,7 @@ while True:
328
325
  pip install 'gitcode-api[mcp]'
329
326
  ```
330
327
 
331
- - **`create_mcp_server`** — builds a `FastMCP` instance with `gitcode_api_tool` already registered; optional `name=`, `tool=`, and extra keyword arguments are forwarded to `FastMCP(...)`.
328
+ - **`create_mcp_server`** — builds a `FastMCP` instance with `gitcode_api_tool` already registered; optional `name`, `tool`, and extra keyword arguments are forwarded to `FastMCP(...)`.
332
329
  - **`GitCodeMCP`** — thin wrapper that constructs that server and registers the tool; unknown attributes are delegated to the underlying `FastMCP` object (for example transport helpers exposed by your FastMCP version).
333
330
  - **`create_mcp_gitcode_api_tool`** — returns the standalone async callable used as the tool body (for custom wiring).
334
331
  - **`register_mcp_gitcode_api_tool`** — attaches that callable to an existing FastMCP-compatible object (`mcp.tool(...)` or `mcp.add_tool(...)`).
@@ -342,7 +339,7 @@ mcp = create_mcp_server(name="GitCode API", owner="SushiNinja", repo="GitCode-AP
342
339
 
343
340
  The same server is available from the CLI as `gitcode-api serve` (see the [CLI](#cli) section).
344
341
 
345
- To share auth or clients across tools, build `GitCodeLLMTool` once (`from gitcode_api.llm._tool import GitCodeLLMTool`) and pass it as `tool=` into `GitCodeMCP`, `create_mcp_server`, `register_mcp_gitcode_api_tool`, or `create_mcp_gitcode_api_tool`.
342
+ To share auth or clients across tools, build `GitCodeLLMTool` once (`from gitcode_api.llm._tool import GitCodeLLMTool`) and pass it as `tool` into `GitCodeMCP`, `create_mcp_server`, `register_mcp_gitcode_api_tool`, or `create_mcp_gitcode_api_tool`.
346
343
 
347
344
  ### openJiuwen (`LocalFunction`)
348
345
 
@@ -360,7 +357,7 @@ jiuwen_tool = create_openjiuwen_gitcode_api_tool(owner="SushiNinja", repo="GitCo
360
357
  # await jiuwen_tool.invoke({"op_type": "repos", "action": "get", "params": {}})
361
358
  ```
362
359
 
363
- Optional `name=` and `description=` override the default tool card. Constructor options otherwise mirror `GitCode` / `AsyncGitCode` (`client=`, `async_client=`, `api_key=`, `owner=`, `repo=`, `base_url=`, `timeout=`, `decrypt=`).
360
+ Optional `name` and `description` override the default tool card. Constructor options otherwise mirror `GitCode` / `AsyncGitCode` (`client`, `async_client`, `api_key`, `owner`, `repo`, `base_url`, `timeout`, `decrypt`).
364
361
 
365
362
  **Claude Desktop (MCPB):** published GitHub Releases include a `gitcode-<version>.mcpb` bundle for one-click installation as a Claude Desktop extension; see Anthropic’s guide, [Build a desktop extension with MCPB](https://claude.com/docs/connectors/building/mcpb). From a checkout you can run `make mcpb` (requires the [`@anthropic-ai/mcpb`](https://www.npmjs.com/package/@anthropic-ai/mcpb) CLI on your `PATH`).
366
363
 
@@ -431,7 +428,7 @@ with GitCode(
431
428
 
432
429
  Use `httpx.AsyncClient(verify=...)` with `AsyncGitCode` for async code.
433
430
 
434
- The OpenAI tool (`GitCodeOpenAITool`), MCP helpers, and `create_openjiuwen_gitcode_api_tool` accept the same `client=` / `async_client=` arguments (OpenAI and MCP also accept a shared `GitCodeLLMTool` via `tool=`). Build `GitCode` / `AsyncGitCode` with your custom `http_client` once and pass it through so LLM tool calls reuse the same TLS settings.
431
+ The OpenAI tool (`GitCodeOpenAITool`), MCP helpers, and `create_openjiuwen_gitcode_api_tool` accept the same `client` / `async_client` arguments (OpenAI and MCP also accept a shared `GitCodeLLMTool` via `tool`). Build `GitCode` / `AsyncGitCode` with your custom `http_client` once and pass it through so LLM tool calls reuse the same TLS settings.
435
432
 
436
433
  ## Project Status
437
434
 
@@ -1,12 +1,9 @@
1
- # GitCode-API
2
-
3
- [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F&uuid=c9611358e1474a759d09ac0b861d8d22)](https://pypi.org/project/gitcode-api) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/gitcode-api?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=downloads&uuid=c9611358e1474a759d09ac0b861d8d22)](https://pepy.tech/projects/gitcode-api)
4
- [![Install in Cursor](https://img.shields.io/badge/Install_in-Cursor-000000?logoColor=white)](https://cursor.com/en/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19) [![Install in VS Code](https://img.shields.io/badge/Install_in-VS_Code-0098FF?logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=GitCode%20API&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22--from%22%2C%22gitcode-api%5Bmcp%5D%22%2C%22gitcode-api%22%2C%22serve%22%5D%2C%22env%22%3A%7B%22GITCODE_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agitcode_access_token%7D%22%7D%2C%22inputs%22%3A%5B%7B%22id%22%3A%22gitcode_access_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Enter%20GITCODE_ACCESS_TOKEN%22%2C%22password%22%3Atrue%7D%5D%7D)
5
- [![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API)](https://github.com/Trenza1ore/GitCode-API) [![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API)](https://gitcode.com/SushiNinja/GitCode-API) [![CI Badge](https://github.com/Trenza1ore/GitCode-API/actions/workflows/check-code.yml/badge.svg?uuid=c9611358e1474a759d09ac0b861d8d22)](https://github.com/Trenza1ore/GitCode-API/actions/workflows/check-code.yml/)
1
+ # GitCode-API [![GitCode Badge](https://img.shields.io/badge/gitcode-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API)](https://gitcode.com/SushiNinja/GitCode-API) [![GitHub Badge](https://img.shields.io/badge/github-black?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API)](https://github.com/Trenza1ore/GitCode-API)
2
+ [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?color=blue&uuid=96abf98469db4ee7bc12ded4646e76d9)](https://pypi.org/project/gitcode-api) [![PyPI - Downloads](https://img.shields.io/pypi/dm/gitcode-api?color=blue&logo=pypi&logoColor=white&label=PyPI%20%E2%86%93&uuid=96abf98469db4ee7bc12ded4646e76d9)](https://pepy.tech/projects/gitcode-api) ![MCP Bundle Downloads](https://img.shields.io/github/downloads/Trenza1ore/GitCode-API/total?color=blue&logo=modelcontextprotocol&label=MCPB%20%E2%86%93&uuid=96abf98469db4ee7bc12ded4646e76d9)
6
3
 
7
4
  [![Docs](https://img.shields.io/badge/%E6%96%87%E6%A1%A3-Docs-cyan?style=for-the-badge&logo=readthedocs&link=https%3A%2F%2Fgitcode-api.readthedocs.io%2Fen%2Flatest%2Findex.html)](https://gitcode-api.readthedocs.io) [![中文README](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-README-brown?style=for-the-badge&logo=googledocs&link=README.zh.md)](README.zh.md)
8
5
 
9
- `gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, repository-scoped helpers, and lightweight response models so you can work with GitCode from Python without hand-writing raw HTTP requests. The `gitcode_api.llm` module adds an OpenAI-style function tool, an MCP service, and an [openJiuwen](https://openjiuwen.com) tool integration so agents can reuse the same resource-oriented API.
6
+ `gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, helpers methods grouped by resource groups, and type-hinted response models so you can work with GitCode from Python without hand-writing raw HTTP requests. The `gitcode_api.llm` module adds an OpenAI-style function tool, an MCP service, and an [openJiuwen](https://openjiuwen.com) tool integration so agents can reuse the same resource-oriented API.
10
7
 
11
8
  ## Why This Project
12
9
 
@@ -14,7 +11,7 @@
14
11
  - Sync and async clients with a consistent API surface.
15
12
  - Convenient methods not offered by REST API directly: such as fetching Issue and PR templates.
16
13
  - Resource groups such as `client.repos`, `client.pulls`, and `client.users`.
17
- - Repository defaults via `owner=` and `repo=` on the client.
14
+ - Repository defaults via `owner` and `repo` on the client.
18
15
  - Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
19
16
  - Provides MCP server, OpenAI tool, and [openJiuwen](https://openjiuwen.com) tool for LLM agent usage.
20
17
  - Provide MCP service that directly installs to your IDE of choice, such as Cursor and VS Code!
@@ -40,14 +37,14 @@ For detailed setup (including installing to services like Claude Code / Codex):
40
37
 
41
38
  ## Authentication
42
39
 
43
- Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
40
+ Pass `api_key` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
44
41
 
45
42
  ```bash
46
43
  export GITCODE_ACCESS_TOKEN="your-token"
47
44
  ```
48
45
 
49
- If your token is stored in encrypted form, pass `decrypt=` to decode either an
50
- encrypted `api_key=` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
46
+ If your token is stored in encrypted form, pass `decrypt` to decode either an
47
+ encrypted `api_key` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
51
48
  the client uses it.
52
49
 
53
50
  ```python
@@ -134,7 +131,7 @@ meta = as_dict(repo) # dict
134
131
 
135
132
  ### Context managers
136
133
 
137
- `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
134
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
138
135
 
139
136
  ```python
140
137
  from gitcode_api import GitCode
@@ -291,7 +288,7 @@ while True:
291
288
  pip install 'gitcode-api[mcp]'
292
289
  ```
293
290
 
294
- - **`create_mcp_server`** — builds a `FastMCP` instance with `gitcode_api_tool` already registered; optional `name=`, `tool=`, and extra keyword arguments are forwarded to `FastMCP(...)`.
291
+ - **`create_mcp_server`** — builds a `FastMCP` instance with `gitcode_api_tool` already registered; optional `name`, `tool`, and extra keyword arguments are forwarded to `FastMCP(...)`.
295
292
  - **`GitCodeMCP`** — thin wrapper that constructs that server and registers the tool; unknown attributes are delegated to the underlying `FastMCP` object (for example transport helpers exposed by your FastMCP version).
296
293
  - **`create_mcp_gitcode_api_tool`** — returns the standalone async callable used as the tool body (for custom wiring).
297
294
  - **`register_mcp_gitcode_api_tool`** — attaches that callable to an existing FastMCP-compatible object (`mcp.tool(...)` or `mcp.add_tool(...)`).
@@ -305,7 +302,7 @@ mcp = create_mcp_server(name="GitCode API", owner="SushiNinja", repo="GitCode-AP
305
302
 
306
303
  The same server is available from the CLI as `gitcode-api serve` (see the [CLI](#cli) section).
307
304
 
308
- To share auth or clients across tools, build `GitCodeLLMTool` once (`from gitcode_api.llm._tool import GitCodeLLMTool`) and pass it as `tool=` into `GitCodeMCP`, `create_mcp_server`, `register_mcp_gitcode_api_tool`, or `create_mcp_gitcode_api_tool`.
305
+ To share auth or clients across tools, build `GitCodeLLMTool` once (`from gitcode_api.llm._tool import GitCodeLLMTool`) and pass it as `tool` into `GitCodeMCP`, `create_mcp_server`, `register_mcp_gitcode_api_tool`, or `create_mcp_gitcode_api_tool`.
309
306
 
310
307
  ### openJiuwen (`LocalFunction`)
311
308
 
@@ -323,7 +320,7 @@ jiuwen_tool = create_openjiuwen_gitcode_api_tool(owner="SushiNinja", repo="GitCo
323
320
  # await jiuwen_tool.invoke({"op_type": "repos", "action": "get", "params": {}})
324
321
  ```
325
322
 
326
- Optional `name=` and `description=` override the default tool card. Constructor options otherwise mirror `GitCode` / `AsyncGitCode` (`client=`, `async_client=`, `api_key=`, `owner=`, `repo=`, `base_url=`, `timeout=`, `decrypt=`).
323
+ Optional `name` and `description` override the default tool card. Constructor options otherwise mirror `GitCode` / `AsyncGitCode` (`client`, `async_client`, `api_key`, `owner`, `repo`, `base_url`, `timeout`, `decrypt`).
327
324
 
328
325
  **Claude Desktop (MCPB):** published GitHub Releases include a `gitcode-<version>.mcpb` bundle for one-click installation as a Claude Desktop extension; see Anthropic’s guide, [Build a desktop extension with MCPB](https://claude.com/docs/connectors/building/mcpb). From a checkout you can run `make mcpb` (requires the [`@anthropic-ai/mcpb`](https://www.npmjs.com/package/@anthropic-ai/mcpb) CLI on your `PATH`).
329
326
 
@@ -394,7 +391,7 @@ with GitCode(
394
391
 
395
392
  Use `httpx.AsyncClient(verify=...)` with `AsyncGitCode` for async code.
396
393
 
397
- The OpenAI tool (`GitCodeOpenAITool`), MCP helpers, and `create_openjiuwen_gitcode_api_tool` accept the same `client=` / `async_client=` arguments (OpenAI and MCP also accept a shared `GitCodeLLMTool` via `tool=`). Build `GitCode` / `AsyncGitCode` with your custom `http_client` once and pass it through so LLM tool calls reuse the same TLS settings.
394
+ The OpenAI tool (`GitCodeOpenAITool`), MCP helpers, and `create_openjiuwen_gitcode_api_tool` accept the same `client` / `async_client` arguments (OpenAI and MCP also accept a shared `GitCodeLLMTool` via `tool`). Build `GitCode` / `AsyncGitCode` with your custom `http_client` once and pass it through so LLM tool calls reuse the same TLS settings.
398
395
 
399
396
  ## Project Status
400
397
 
@@ -1,16 +1,18 @@
1
- """Public package exports for the GitCode SDK."""
1
+ """GitCode API Python clients for interactions with GitCode REST API."""
2
2
 
3
3
  import re
4
4
  from importlib.metadata import PackageNotFoundError, metadata, version
5
5
  from typing import cast
6
6
 
7
- from . import constants
7
+ from . import constants, exceptions, models
8
8
  from ._client import AsyncGitCode, GitCode
9
9
  from ._exceptions import (
10
10
  GitCodeAPIError,
11
11
  GitCodeConfigurationError,
12
12
  GitCodeError,
13
13
  GitCodeHTTPStatusError,
14
+ GitCodeTokenError,
15
+ GitCodeUnauthorizedError,
14
16
  )
15
17
  from .utils import as_dict
16
18
 
@@ -43,6 +45,8 @@ __version__ = _VERSION_STR.strip()
43
45
 
44
46
  __all__ = [
45
47
  "constants",
48
+ "exceptions",
49
+ "models",
46
50
  "__version__",
47
51
  "__build_hash__",
48
52
  "AsyncGitCode",
@@ -51,5 +55,7 @@ __all__ = [
51
55
  "GitCodeConfigurationError",
52
56
  "GitCodeError",
53
57
  "GitCodeHTTPStatusError",
58
+ "GitCodeTokenError",
59
+ "GitCodeUnauthorizedError",
54
60
  "as_dict",
55
61
  ]
@@ -38,8 +38,10 @@ class GitCodeAPIError(GitCodeError):
38
38
  class GitCodeHTTPStatusError(GitCodeAPIError):
39
39
  """Raised for non-success HTTP responses from the GitCode API."""
40
40
 
41
+
41
42
  class GitCodeUnauthorizedError(GitCodeHTTPStatusError):
42
43
  """Raised for 401 unauthorized HTTP responses from the GitCode API."""
43
44
 
45
+
44
46
  class GitCodeTokenError(GitCodeUnauthorizedError):
45
47
  """Raised for invalid token from the GitCode API."""
@@ -0,0 +1,19 @@
1
+ """Exception classes for the GitCode SDK."""
2
+
3
+ from gitcode_api._exceptions import (
4
+ GitCodeAPIError,
5
+ GitCodeConfigurationError,
6
+ GitCodeError,
7
+ GitCodeHTTPStatusError,
8
+ GitCodeTokenError,
9
+ GitCodeUnauthorizedError,
10
+ )
11
+
12
+ __all__ = [
13
+ "GitCodeAPIError",
14
+ "GitCodeConfigurationError",
15
+ "GitCodeError",
16
+ "GitCodeHTTPStatusError",
17
+ "GitCodeTokenError",
18
+ "GitCodeUnauthorizedError",
19
+ ]
@@ -1,6 +1,6 @@
1
1
  """FastMCP integration for the GitCode LLM tool."""
2
2
 
3
- from typing import TYPE_CHECKING, Any, Callable, Optional, Union
3
+ from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
4
4
 
5
5
  from ._tool import (
6
6
  MCP_SERVER_INSTRUCTIONS,
@@ -25,8 +25,8 @@ def _missing_fastmcp_error() -> ImportError:
25
25
 
26
26
  def _load_fastmcp() -> tuple["type[FastMCP]", Callable[..., "Tool"]]:
27
27
  try:
28
- from fastmcp import FastMCP
29
- from fastmcp.tools import tool as fastmcp_tool
28
+ from fastmcp import FastMCP # pylint: disable=import-outside-toplevel
29
+ from fastmcp.tools import tool as fastmcp_tool # pylint: disable=import-outside-toplevel
30
30
  except ImportError as exc:
31
31
  raise _missing_fastmcp_error() from exc
32
32
  return FastMCP, fastmcp_tool # type: ignore[return-value]
@@ -61,9 +61,9 @@ def register_mcp_gitcode_api_tool(mcp: Union["FastMCP", Any], tool: Optional[Git
61
61
  callable_tool = create_mcp_gitcode_api_tool(tool)
62
62
  if hasattr(mcp, "tool"):
63
63
  try:
64
- return mcp.tool(name=TOOL_NAME, description=TOOL_DESCRIPTION)(callable_tool)
64
+ return cast("Tool", mcp.tool(name=TOOL_NAME, description=TOOL_DESCRIPTION)(callable_tool))
65
65
  except TypeError:
66
- return mcp.tool()(callable_tool)
66
+ return cast("Tool", mcp.tool()(callable_tool))
67
67
  if hasattr(mcp, "add_tool"):
68
68
  _, fastmcp_tool = _load_fastmcp()
69
69
  mcp_tool = fastmcp_tool(callable_tool, name=TOOL_NAME, description=TOOL_DESCRIPTION)
@@ -136,7 +136,7 @@ def create_mcp_server(name: str = "GitCode API", tool: Optional[GitCodeLLMTool]
136
136
  :param name: MCP server display name.
137
137
  :param tool: Optional preconfigured :class:`~gitcode_api.llm._tool.GitCodeLLMTool`.
138
138
  :param kwargs: Forwarded to :class:`GitCodeMCP` and then to ``fastmcp.FastMCP`` (for example
139
- ``instructions=`` to override the default server instructions).
139
+ ``instructions`` to override the default server instructions).
140
140
  :returns: Configured ``FastMCP`` instance with ``gitcode_api_tool`` registered.
141
141
  """
142
142
  return GitCodeMCP(name=name, tool=tool, **kwargs).mcp
@@ -0,0 +1,205 @@
1
+ """Response models for the GitCode SDK."""
2
+
3
+ from gitcode_api._models import (
4
+ APIObject,
5
+ ApiStatusResponse,
6
+ Blob,
7
+ Branch,
8
+ BranchDetail,
9
+ BranchDetailCommit,
10
+ BranchListCommit,
11
+ Commit,
12
+ CommitAuthorSummary,
13
+ CommitComment,
14
+ CommitComparison,
15
+ CommitFile,
16
+ CommitIdentity,
17
+ CommitParent,
18
+ CommitPayload,
19
+ CommitResult,
20
+ CommitStats,
21
+ CommitSummary,
22
+ CommitTreeRef,
23
+ ContentLinks,
24
+ ContentObject,
25
+ ContentWriteCommit,
26
+ Contributor,
27
+ ContributorStatistics,
28
+ ContributorStatisticsEntry,
29
+ ContributorStatisticsOverview,
30
+ Email,
31
+ EmptyResponse,
32
+ EnterpriseMember,
33
+ EnterpriseRef,
34
+ Issue,
35
+ IssueComment,
36
+ IssueOperationLog,
37
+ Label,
38
+ MergeResult,
39
+ MergeStatus,
40
+ Milestone,
41
+ Namespace,
42
+ NamespaceDetails,
43
+ OAuthToken,
44
+ Organization,
45
+ OrganizationMembership,
46
+ OrganizationSummary,
47
+ ProtectedBranch,
48
+ ProtectedTag,
49
+ PublicKey,
50
+ PullRequest,
51
+ PullRequestApprover,
52
+ PullRequestAssigneeCount,
53
+ PullRequestBranch,
54
+ PullRequestComment,
55
+ PullRequestCount,
56
+ PullRequestDiffRefs,
57
+ PullRequestFile,
58
+ PullRequestOperationLog,
59
+ PullRequestReview,
60
+ PullRequestSettingDetail,
61
+ PullRequestSettings,
62
+ PullRequestTest,
63
+ PullRequestTimeStats,
64
+ Release,
65
+ ReleaseAsset,
66
+ ReleaseUploadURL,
67
+ RepoCollaborator,
68
+ RepoMember,
69
+ RepoMemberPermission,
70
+ RepoMemberPermissions,
71
+ Repository,
72
+ RepositoryCollaboratorCheck,
73
+ RepositoryCustomizedRole,
74
+ RepositoryDownloadStatistics,
75
+ RepositoryDownloadStatisticsDetail,
76
+ RepositoryGitCodeTemplate,
77
+ RepositoryPermission,
78
+ RepositoryPermissionMode,
79
+ RepositoryPushConfig,
80
+ RepositoryReviewerSettingsUpdate,
81
+ RepositorySettings,
82
+ RepositorySummary,
83
+ RepositoryTransferResult,
84
+ RepositoryUploadResult,
85
+ SearchIssue,
86
+ SearchRepository,
87
+ SearchResult,
88
+ SearchUser,
89
+ Tag,
90
+ TagCommit,
91
+ Tagger,
92
+ Tree,
93
+ TreeEntry,
94
+ User,
95
+ UserEvent,
96
+ UserEventLinks,
97
+ UserEventProject,
98
+ UserEventPushData,
99
+ UserEventsResponse,
100
+ UserRef,
101
+ UserSummary,
102
+ Webhook,
103
+ )
104
+
105
+ __all__ = [
106
+ "APIObject",
107
+ "ApiStatusResponse",
108
+ "Blob",
109
+ "Branch",
110
+ "BranchDetail",
111
+ "BranchDetailCommit",
112
+ "BranchListCommit",
113
+ "Commit",
114
+ "CommitAuthorSummary",
115
+ "CommitComment",
116
+ "CommitComparison",
117
+ "CommitFile",
118
+ "CommitIdentity",
119
+ "CommitParent",
120
+ "CommitPayload",
121
+ "CommitResult",
122
+ "CommitStats",
123
+ "CommitSummary",
124
+ "CommitTreeRef",
125
+ "ContentLinks",
126
+ "ContentObject",
127
+ "ContentWriteCommit",
128
+ "Contributor",
129
+ "ContributorStatistics",
130
+ "ContributorStatisticsEntry",
131
+ "ContributorStatisticsOverview",
132
+ "Email",
133
+ "EmptyResponse",
134
+ "EnterpriseMember",
135
+ "EnterpriseRef",
136
+ "Issue",
137
+ "IssueComment",
138
+ "IssueOperationLog",
139
+ "Label",
140
+ "MergeResult",
141
+ "MergeStatus",
142
+ "Milestone",
143
+ "Namespace",
144
+ "NamespaceDetails",
145
+ "OAuthToken",
146
+ "Organization",
147
+ "OrganizationMembership",
148
+ "OrganizationSummary",
149
+ "ProtectedBranch",
150
+ "ProtectedTag",
151
+ "PublicKey",
152
+ "PullRequest",
153
+ "PullRequestApprover",
154
+ "PullRequestAssigneeCount",
155
+ "PullRequestBranch",
156
+ "PullRequestComment",
157
+ "PullRequestCount",
158
+ "PullRequestDiffRefs",
159
+ "PullRequestFile",
160
+ "PullRequestOperationLog",
161
+ "PullRequestReview",
162
+ "PullRequestSettingDetail",
163
+ "PullRequestSettings",
164
+ "PullRequestTest",
165
+ "PullRequestTimeStats",
166
+ "Release",
167
+ "ReleaseAsset",
168
+ "ReleaseUploadURL",
169
+ "RepoCollaborator",
170
+ "RepoMember",
171
+ "RepoMemberPermission",
172
+ "RepoMemberPermissions",
173
+ "Repository",
174
+ "RepositoryCollaboratorCheck",
175
+ "RepositoryCustomizedRole",
176
+ "RepositoryDownloadStatistics",
177
+ "RepositoryDownloadStatisticsDetail",
178
+ "RepositoryGitCodeTemplate",
179
+ "RepositoryPermission",
180
+ "RepositoryPermissionMode",
181
+ "RepositoryPushConfig",
182
+ "RepositoryReviewerSettingsUpdate",
183
+ "RepositorySettings",
184
+ "RepositorySummary",
185
+ "RepositoryTransferResult",
186
+ "RepositoryUploadResult",
187
+ "SearchIssue",
188
+ "SearchRepository",
189
+ "SearchResult",
190
+ "SearchUser",
191
+ "Tag",
192
+ "TagCommit",
193
+ "Tagger",
194
+ "Tree",
195
+ "TreeEntry",
196
+ "User",
197
+ "UserEvent",
198
+ "UserEventLinks",
199
+ "UserEventProject",
200
+ "UserEventPushData",
201
+ "UserEventsResponse",
202
+ "UserRef",
203
+ "UserSummary",
204
+ "Webhook",
205
+ ]
@@ -1,4 +1,4 @@
1
- """Public resource group exports for the GitCode SDK."""
1
+ """Sync and async resource group classes for all API endpoint families."""
2
2
 
3
3
  from .account import (
4
4
  AsyncOAuthResource,
@@ -0,0 +1,18 @@
1
+ """Shared resource base classes and template helpers."""
2
+
3
+ from .base import AsyncResource, SyncResource
4
+ from .fetch_template import (
5
+ get_gitcode_template_body_async,
6
+ get_gitcode_template_body_sync,
7
+ list_gitcode_template_rows_async,
8
+ list_gitcode_template_rows_sync,
9
+ )
10
+
11
+ __all__ = [
12
+ "AsyncResource",
13
+ "SyncResource",
14
+ "get_gitcode_template_body_sync",
15
+ "get_gitcode_template_body_async",
16
+ "list_gitcode_template_rows_sync",
17
+ "list_gitcode_template_rows_async",
18
+ ]