gitcode-api 1.2.6__py3-none-any.whl → 1.2.7__py3-none-any.whl
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.
- gitcode_api/llm/__init__.py +9 -1
- gitcode_api/llm/_tool.py +71 -9
- gitcode_api/llm/mcp.py +68 -9
- gitcode_api/version.txt +1 -1
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/METADATA +15 -2
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/RECORD +10 -10
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/WHEEL +0 -0
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/entry_points.txt +0 -0
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/licenses/LICENSE +0 -0
- {gitcode_api-1.2.6.dist-info → gitcode_api-1.2.7.dist-info}/top_level.txt +0 -0
gitcode_api/llm/__init__.py
CHANGED
|
@@ -4,7 +4,13 @@ from importlib import import_module
|
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Dict
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
|
-
from .mcp import
|
|
7
|
+
from .mcp import (
|
|
8
|
+
GitCodeMCP,
|
|
9
|
+
create_mcp_gitcode_api_tool,
|
|
10
|
+
create_mcp_server,
|
|
11
|
+
register_mcp_gitcode_api_tool,
|
|
12
|
+
register_mcp_help_resources,
|
|
13
|
+
)
|
|
8
14
|
from .openai import GitCodeOpenAITool
|
|
9
15
|
|
|
10
16
|
|
|
@@ -13,6 +19,7 @@ _IMPORT_MAP = {
|
|
|
13
19
|
"create_mcp_gitcode_api_tool": ".mcp",
|
|
14
20
|
"create_mcp_server": ".mcp",
|
|
15
21
|
"register_mcp_gitcode_api_tool": ".mcp",
|
|
22
|
+
"register_mcp_help_resources": ".mcp",
|
|
16
23
|
"GitCodeOpenAITool": ".openai",
|
|
17
24
|
}
|
|
18
25
|
|
|
@@ -46,4 +53,5 @@ __all__ = [
|
|
|
46
53
|
"create_mcp_gitcode_api_tool",
|
|
47
54
|
"create_mcp_server",
|
|
48
55
|
"register_mcp_gitcode_api_tool",
|
|
56
|
+
"register_mcp_help_resources",
|
|
49
57
|
]
|
gitcode_api/llm/_tool.py
CHANGED
|
@@ -26,9 +26,29 @@ OP_TYPES = frozenset(
|
|
|
26
26
|
if inspect.isclass(annotation) and issubclass(annotation, SyncResource)
|
|
27
27
|
)
|
|
28
28
|
OP_TYPE_ENUM = sorted(OP_TYPES)
|
|
29
|
+
|
|
30
|
+
MCP_SERVER_INSTRUCTIONS = (
|
|
31
|
+
"This MCP server exposes the GitCode REST API through the gitcode-api package.\n\n"
|
|
32
|
+
"Use the single tool gitcode_api_tool with:\n"
|
|
33
|
+
"- op_type (required): client resource groups (same attribute names as on GitCode).\n"
|
|
34
|
+
"- action: the method on that resource (for example get, list).\n"
|
|
35
|
+
"- params: keyword arguments for that method as a JSON object; omit or null means {}.\n"
|
|
36
|
+
"- help: when true, returns formatted help (available methods or a method signature) instead of "
|
|
37
|
+
"calling the API where applicable.\n\n"
|
|
38
|
+
"Successful results are JSON-serializable. Raw bytes from endpoints such as contents.get_raw are "
|
|
39
|
+
'returned as {"encoding": "base64", "data": "<ascii>"}.\n'
|
|
40
|
+
'Failures are objects with "error": true and a "message" string.\n\n'
|
|
41
|
+
"Valid op_type values for this client version:\n- "
|
|
42
|
+
+ "\n- ".join(OP_TYPE_ENUM)
|
|
43
|
+
+ "\n\n"
|
|
44
|
+
"Optional MCP resources (read without calling the tool):\n"
|
|
45
|
+
"- gitcode-api://help — markdown index of help URIs\n"
|
|
46
|
+
"- gitcode-api://help/{op_type} — plain-text method list for that client resource\n"
|
|
47
|
+
)
|
|
48
|
+
|
|
29
49
|
TOOL_NAME = "gitcode_api_tool"
|
|
30
50
|
TOOL_DESCRIPTION = (
|
|
31
|
-
"Call the GitCode REST API through the gitcode-api
|
|
51
|
+
"Call the GitCode REST API through the gitcode-api client. Use op_type to choose a client resource group, "
|
|
32
52
|
"action as the resource method name, and params as the keyword arguments for that method. Set help=true to "
|
|
33
53
|
"inspect available resource methods or a target method signature without sending an API request."
|
|
34
54
|
)
|
|
@@ -38,7 +58,7 @@ TOOL_PARAMETERS = {
|
|
|
38
58
|
"op_type": {
|
|
39
59
|
"type": "string",
|
|
40
60
|
"enum": OP_TYPE_ENUM,
|
|
41
|
-
"description": "
|
|
61
|
+
"description": "Resource group matching client.<op_type>, such as repos, issues, or pulls.",
|
|
42
62
|
},
|
|
43
63
|
"action": {
|
|
44
64
|
"type": "string",
|
|
@@ -46,11 +66,11 @@ TOOL_PARAMETERS = {
|
|
|
46
66
|
},
|
|
47
67
|
"params": {
|
|
48
68
|
"type": "object",
|
|
49
|
-
"description": "Keyword arguments passed to the
|
|
69
|
+
"description": "Keyword arguments passed to the client method. Omitted or null is treated as {}.",
|
|
50
70
|
},
|
|
51
71
|
"help": {
|
|
52
72
|
"type": "boolean",
|
|
53
|
-
"description": "When true, return dynamic
|
|
73
|
+
"description": "When true, return dynamic client help instead of sending a request.",
|
|
54
74
|
"default": False,
|
|
55
75
|
},
|
|
56
76
|
},
|
|
@@ -73,7 +93,7 @@ def error_dict(message: str, **extra: Any) -> Dict[str, Any]:
|
|
|
73
93
|
|
|
74
94
|
|
|
75
95
|
def serialize(value: Any) -> Any:
|
|
76
|
-
"""Convert
|
|
96
|
+
"""Convert client responses into JSON-serializable values for tool clients."""
|
|
77
97
|
if value is None or isinstance(value, (bool, int, float, str)):
|
|
78
98
|
return value
|
|
79
99
|
if isinstance(value, bytes):
|
|
@@ -129,6 +149,44 @@ def _format_action_help(*, op_type: str, resource: Any, action: str) -> str:
|
|
|
129
149
|
return _format_help(op_type=op_type, resource=None, header=header)
|
|
130
150
|
|
|
131
151
|
|
|
152
|
+
def op_type_help_resource_body(op_type: str) -> str:
|
|
153
|
+
"""Return plain-text method list for one ``op_type``.
|
|
154
|
+
|
|
155
|
+
Content matches :meth:`GitCodeLLMTool.__async_call__` with ``help=true`` and an empty ``action``.
|
|
156
|
+
|
|
157
|
+
:param op_type: Resource attribute name on :class:`~gitcode_api.GitCode`.
|
|
158
|
+
:returns: Help body for MCP ``gitcode-api://help/{op_type}`` resources.
|
|
159
|
+
"""
|
|
160
|
+
if op_type not in OP_TYPES:
|
|
161
|
+
allowed = ", ".join(OP_TYPE_ENUM)
|
|
162
|
+
return f"Unknown op_type {op_type!r}. Allowed: {allowed}."
|
|
163
|
+
resource = resource_for_op_type(op_type)
|
|
164
|
+
header = "Specify non-empty action to invoke a method. Available methods:"
|
|
165
|
+
return _format_help(op_type=op_type, resource=resource, header=header)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def help_resource_index_body() -> str:
|
|
169
|
+
"""Return markdown listing ``gitcode-api://help/<op_type>`` URIs for MCP discovery.
|
|
170
|
+
|
|
171
|
+
:returns: Index body for MCP ``gitcode-api://help``.
|
|
172
|
+
"""
|
|
173
|
+
lines = [
|
|
174
|
+
"# GitCode API — MCP help resources",
|
|
175
|
+
"",
|
|
176
|
+
"Read any URI below for the method list for that `op_type` on `gitcode_api_tool`.",
|
|
177
|
+
"",
|
|
178
|
+
]
|
|
179
|
+
for name in OP_TYPE_ENUM:
|
|
180
|
+
lines.append(f"- gitcode-api://help/{name}")
|
|
181
|
+
lines.extend(
|
|
182
|
+
[
|
|
183
|
+
"",
|
|
184
|
+
"The same text is returned by `gitcode_api_tool` with `help: true` and an empty `action`.",
|
|
185
|
+
]
|
|
186
|
+
)
|
|
187
|
+
return "\n".join(lines)
|
|
188
|
+
|
|
189
|
+
|
|
132
190
|
def validate_call_kwargs(
|
|
133
191
|
fn: Callable[..., Any], params: Optional[Dict[str, Any]]
|
|
134
192
|
) -> Tuple[Optional[Dict[str, Any]], Optional[str]]:
|
|
@@ -191,8 +249,6 @@ class GitCodeLLMTool:
|
|
|
191
249
|
decrypt: Optional[Callable] = None,
|
|
192
250
|
) -> None:
|
|
193
251
|
"""Create a reusable tool with lazy sync and async clients."""
|
|
194
|
-
if not (api_key or os.getenv(DEFAULT_TOKEN_ENV)):
|
|
195
|
-
raise GitCodeConfigurationError("No API key provided. Pass api_key=... or set GITCODE_ACCESS_TOKEN.")
|
|
196
252
|
self._client = client
|
|
197
253
|
self._async_client = async_client
|
|
198
254
|
self._client_kwargs = {
|
|
@@ -204,10 +260,15 @@ class GitCodeLLMTool:
|
|
|
204
260
|
"decrypt": decrypt,
|
|
205
261
|
}
|
|
206
262
|
|
|
263
|
+
def _require_api_key_for_clients(self) -> None:
|
|
264
|
+
if not (self._client_kwargs.get("api_key") or os.getenv(DEFAULT_TOKEN_ENV)):
|
|
265
|
+
raise GitCodeConfigurationError("No API key provided. Pass api_key=... or set GITCODE_ACCESS_TOKEN.")
|
|
266
|
+
|
|
207
267
|
@property
|
|
208
268
|
def client(self) -> GitCode:
|
|
209
269
|
"""Return the synchronous client, creating it lazily when needed."""
|
|
210
270
|
if self._client is None:
|
|
271
|
+
self._require_api_key_for_clients()
|
|
211
272
|
self._client = GitCode(**self._client_kwargs) # type: ignore[arg-type]
|
|
212
273
|
return self._client
|
|
213
274
|
|
|
@@ -215,6 +276,7 @@ class GitCodeLLMTool:
|
|
|
215
276
|
def async_client(self) -> AsyncGitCode:
|
|
216
277
|
"""Return the asynchronous client, creating it lazily when needed."""
|
|
217
278
|
if self._async_client is None:
|
|
279
|
+
self._require_api_key_for_clients()
|
|
218
280
|
self._async_client = AsyncGitCode(**self._client_kwargs) # type: ignore[arg-type]
|
|
219
281
|
return self._async_client
|
|
220
282
|
|
|
@@ -226,7 +288,7 @@ class GitCodeLLMTool:
|
|
|
226
288
|
help: bool = False,
|
|
227
289
|
**kwargs,
|
|
228
290
|
) -> Any:
|
|
229
|
-
"""Invoke a synchronous GitCode
|
|
291
|
+
"""Invoke a synchronous GitCode client method through the tool contract."""
|
|
230
292
|
if kwargs:
|
|
231
293
|
return error_dict('Invalid tool invoke, API parameters should go into "params"')
|
|
232
294
|
return self._invoke(op_type=op_type, action=action, params=params, help=help)
|
|
@@ -239,7 +301,7 @@ class GitCodeLLMTool:
|
|
|
239
301
|
help: bool = False,
|
|
240
302
|
**kwargs,
|
|
241
303
|
) -> Any:
|
|
242
|
-
"""Invoke an asynchronous GitCode
|
|
304
|
+
"""Invoke an asynchronous GitCode client method through the tool contract."""
|
|
243
305
|
if kwargs:
|
|
244
306
|
return error_dict('Invalid tool invoke, API parameters should go into "params"')
|
|
245
307
|
return await self._ainvoke(op_type=op_type, action=action, params=params, help=help)
|
gitcode_api/llm/mcp.py
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
"""FastMCP integration for the GitCode
|
|
1
|
+
"""FastMCP integration for the GitCode LLM tool."""
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
|
|
4
4
|
|
|
5
|
-
from ._tool import
|
|
5
|
+
from ._tool import (
|
|
6
|
+
MCP_SERVER_INSTRUCTIONS,
|
|
7
|
+
TOOL_DESCRIPTION,
|
|
8
|
+
TOOL_NAME,
|
|
9
|
+
GitCodeLLMTool,
|
|
10
|
+
help_resource_index_body,
|
|
11
|
+
op_type_help_resource_body,
|
|
12
|
+
)
|
|
6
13
|
|
|
7
14
|
if TYPE_CHECKING:
|
|
8
15
|
from fastmcp import FastMCP
|
|
@@ -25,7 +32,7 @@ def _load_fastmcp() -> tuple["type[FastMCP]", Callable[..., "Tool"]]:
|
|
|
25
32
|
return FastMCP, fastmcp_tool # type: ignore[return-value]
|
|
26
33
|
|
|
27
34
|
|
|
28
|
-
def create_mcp_gitcode_api_tool(tool: Optional[GitCodeLLMTool] = None) ->
|
|
35
|
+
def create_mcp_gitcode_api_tool(tool: Optional[GitCodeLLMTool] = None) -> Callable:
|
|
29
36
|
"""Return the async callable that can be registered with an MCP server.
|
|
30
37
|
|
|
31
38
|
:param tool: Optional preconfigured shared GitCode LLM tool.
|
|
@@ -36,7 +43,7 @@ def create_mcp_gitcode_api_tool(tool: Optional[GitCodeLLMTool] = None) -> Any:
|
|
|
36
43
|
async def gitcode_api_tool(
|
|
37
44
|
op_type: str, action: str = "", params: Optional[dict[str, Any]] = None, help: bool = False
|
|
38
45
|
) -> Any:
|
|
39
|
-
"""Call GitCode
|
|
46
|
+
"""Call GitCode client resources using op_type, action, and params."""
|
|
40
47
|
return await wrapped.__async_call__(op_type=op_type, action=action, params=params, help=help)
|
|
41
48
|
|
|
42
49
|
gitcode_api_tool.__name__ = TOOL_NAME
|
|
@@ -44,7 +51,7 @@ def create_mcp_gitcode_api_tool(tool: Optional[GitCodeLLMTool] = None) -> Any:
|
|
|
44
51
|
return gitcode_api_tool
|
|
45
52
|
|
|
46
53
|
|
|
47
|
-
def register_mcp_gitcode_api_tool(mcp: Union["FastMCP", Any], tool: Optional[GitCodeLLMTool] = None) ->
|
|
54
|
+
def register_mcp_gitcode_api_tool(mcp: Union["FastMCP", Any], tool: Optional[GitCodeLLMTool] = None) -> "Tool":
|
|
48
55
|
"""Register the GitCode API tool with an existing FastMCP-compatible server.
|
|
49
56
|
|
|
50
57
|
:param mcp: FastMCP server instance.
|
|
@@ -64,27 +71,78 @@ def register_mcp_gitcode_api_tool(mcp: Union["FastMCP", Any], tool: Optional[Git
|
|
|
64
71
|
raise TypeError("mcp must provide a tool decorator or add_tool method")
|
|
65
72
|
|
|
66
73
|
|
|
74
|
+
def register_mcp_help_resources(mcp: Union["FastMCP", Any]) -> None:
|
|
75
|
+
"""Register optional MCP resources that mirror ``gitcode_api_tool`` help text.
|
|
76
|
+
|
|
77
|
+
Registers:
|
|
78
|
+
|
|
79
|
+
* ``gitcode-api://help`` — markdown index of per-``op_type`` URIs.
|
|
80
|
+
* ``gitcode-api://help/{op_type}`` — plain-text method list for one resource.
|
|
81
|
+
|
|
82
|
+
No-op when ``mcp`` does not expose FastMCP's ``resource`` decorator.
|
|
83
|
+
|
|
84
|
+
:param mcp: FastMCP server instance (or compatible object).
|
|
85
|
+
"""
|
|
86
|
+
if not hasattr(mcp, "resource"):
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
@mcp.resource(
|
|
90
|
+
"gitcode-api://help/{op_type}",
|
|
91
|
+
name="gitcode_api_op_type_help",
|
|
92
|
+
description=(
|
|
93
|
+
"Method list for one op_type (same as gitcode_api_tool with help=true and empty action)."
|
|
94
|
+
),
|
|
95
|
+
mime_type="text/plain",
|
|
96
|
+
)
|
|
97
|
+
async def _op_type_help_resource(op_type: str) -> str:
|
|
98
|
+
return op_type_help_resource_body(op_type)
|
|
99
|
+
|
|
100
|
+
@mcp.resource(
|
|
101
|
+
"gitcode-api://help",
|
|
102
|
+
name="gitcode_api_help_index",
|
|
103
|
+
description="Markdown index of gitcode-api://help/{op_type} help resources.",
|
|
104
|
+
mime_type="text/markdown",
|
|
105
|
+
)
|
|
106
|
+
async def _help_index_resource() -> str:
|
|
107
|
+
return help_resource_index_body()
|
|
108
|
+
|
|
109
|
+
_ = (_op_type_help_resource, _help_index_resource)
|
|
110
|
+
|
|
111
|
+
|
|
67
112
|
class GitCodeMCP:
|
|
68
113
|
"""Small FastMCP server wrapper exposing the GitCode API tool.
|
|
69
114
|
|
|
70
115
|
:param name: MCP server name.
|
|
71
116
|
:param tool: Optional preconfigured shared GitCode LLM tool.
|
|
72
|
-
:param kwargs: Forwarded to ``fastmcp.FastMCP``.
|
|
117
|
+
:param kwargs: Forwarded to ``fastmcp.FastMCP``. If ``instructions`` is omitted, a default overview
|
|
118
|
+
of the tool (parameters, byte encoding, and valid ``op_type`` values) is supplied.
|
|
73
119
|
"""
|
|
74
120
|
|
|
75
|
-
def __init__(self, name: str = "GitCode API", tool: Optional[GitCodeLLMTool] = None, **kwargs) -> None:
|
|
121
|
+
def __init__(self, name: str = "GitCode API", tool: Optional[GitCodeLLMTool] = None, **kwargs: Any) -> None:
|
|
76
122
|
"""Create a FastMCP server and register the GitCode API tool."""
|
|
77
123
|
fastmcp, *_ = _load_fastmcp()
|
|
124
|
+
if "instructions" not in kwargs:
|
|
125
|
+
kwargs["instructions"] = MCP_SERVER_INSTRUCTIONS
|
|
78
126
|
self.mcp = fastmcp(name, **kwargs)
|
|
79
127
|
self.gitcode_api_tool = register_mcp_gitcode_api_tool(self.mcp, tool)
|
|
128
|
+
register_mcp_help_resources(self.mcp)
|
|
80
129
|
|
|
81
130
|
def __getattr__(self, name: str) -> Any:
|
|
82
131
|
"""Delegate unknown attributes to the wrapped FastMCP server."""
|
|
83
132
|
return getattr(self.mcp, name)
|
|
84
133
|
|
|
85
134
|
|
|
86
|
-
def create_mcp_server(
|
|
87
|
-
|
|
135
|
+
def create_mcp_server(
|
|
136
|
+
name: str = "GitCode API", tool: Optional[GitCodeLLMTool] = None, **kwargs: Any
|
|
137
|
+
) -> "FastMCP":
|
|
138
|
+
"""Create a FastMCP server with the GitCode API tool already registered.
|
|
139
|
+
|
|
140
|
+
:param name: MCP server display name.
|
|
141
|
+
:param tool: Optional preconfigured :class:`~gitcode_api.llm._tool.GitCodeLLMTool`.
|
|
142
|
+
:param kwargs: Forwarded to :class:`GitCodeMCP` and then to ``fastmcp.FastMCP`` (for example
|
|
143
|
+
``instructions=`` to override the default server instructions).
|
|
144
|
+
:returns: Configured ``FastMCP`` instance with ``gitcode_api_tool`` registered.
|
|
145
|
+
"""
|
|
88
146
|
return GitCodeMCP(name=name, tool=tool, **kwargs).mcp
|
|
89
147
|
|
|
90
148
|
|
|
@@ -93,4 +151,5 @@ __all__ = [
|
|
|
93
151
|
"create_mcp_gitcode_api_tool",
|
|
94
152
|
"create_mcp_server",
|
|
95
153
|
"register_mcp_gitcode_api_tool",
|
|
154
|
+
"register_mcp_help_resources",
|
|
96
155
|
]
|
gitcode_api/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.7
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitcode-api
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.7
|
|
4
4
|
Summary: Easy to use Python SDK for the GitCode REST API. Providing builtin CLI tool, and optional LLM integration (MCP and OpenAI tool) for agents. Community-maintained.
|
|
5
5
|
Author-email: Hugo Huang <hugo@hugohuang.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -34,7 +34,8 @@ Dynamic: license-file
|
|
|
34
34
|
|
|
35
35
|
# GitCode-API
|
|
36
36
|
|
|
37
|
-
[](https://pypi.org/project/gitcode-api) [](https://pepy.tech/projects/gitcode-api) [](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api)
|
|
37
|
+
[](https://pypi.org/project/gitcode-api) [](https://pepy.tech/projects/gitcode-api) [](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api)
|
|
38
|
+
[](https://cursor.com/en/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19) [](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)
|
|
38
39
|
[](https://github.com/Trenza1ore/GitCode-API) [](https://gitcode.com/SushiNinja/GitCode-API)
|
|
39
40
|
|
|
40
41
|
[](https://gitcode-api.readthedocs.io) [](README.zh.md)
|
|
@@ -48,6 +49,8 @@ Dynamic: license-file
|
|
|
48
49
|
- Resource groups such as `client.repos`, `client.pulls`, and `client.users`.
|
|
49
50
|
- Repository defaults via `owner=` and `repo=` on the client.
|
|
50
51
|
- Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
|
|
52
|
+
- Provides MCP server & OpenAI tool for LLM agent usage.
|
|
53
|
+
- Provide MCP service that directly installs to your IDE of choice, such as Cursor and VS Code!
|
|
51
54
|
|
|
52
55
|
## Installation
|
|
53
56
|
|
|
@@ -57,6 +60,16 @@ Install from PyPI:
|
|
|
57
60
|
pip install -U gitcode-api
|
|
58
61
|
```
|
|
59
62
|
|
|
63
|
+
Install the MCP server to your AI-powered IDE of choice:
|
|
64
|
+
[](https://cursor.com/en/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19)
|
|
65
|
+
[](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)
|
|
66
|
+
[](https://insiders.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&quality=insiders)
|
|
67
|
+
[](https://vs-open.link/mcp-install?%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)
|
|
68
|
+
[](https://block.github.io/goose/extension?cmd=uvx&arg=--from%2520gitcode-api%5Bmcp%5D%2520gitcode-api%2520serve&id=GitCode%20API&name=GitCode%20API&description=MCP%20Server%20for%20GitCode%20API)
|
|
69
|
+
[](https://lmstudio.ai/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19)
|
|
70
|
+
|
|
71
|
+
For detailed setup (including installing to services like Claude Code / Codex): see [install_mcp_server.md](install_mcp_server.md).
|
|
72
|
+
|
|
60
73
|
## Authentication
|
|
61
74
|
|
|
62
75
|
Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
|
|
@@ -8,10 +8,10 @@ gitcode_api/_exceptions.py,sha256=T5N8gBGmPSktDkLP5P_hxbzOHw3W378TzxN1xja40pA,11
|
|
|
8
8
|
gitcode_api/_models.py,sha256=v-GZzCGAb3_frY6wFiQww9m271U5MigivpEHDHnoDcI,109030
|
|
9
9
|
gitcode_api/cli.py,sha256=DpnyGP54CkMGWwc8Krakt9i8RtAAsV45sN2UfgwMdIA,16631
|
|
10
10
|
gitcode_api/py.typed,sha256=mDShSrm8qg9qjacQc2F-rI8ATllqP6EdgHuEYxuCXZ0,7
|
|
11
|
-
gitcode_api/version.txt,sha256=
|
|
12
|
-
gitcode_api/llm/__init__.py,sha256=
|
|
13
|
-
gitcode_api/llm/_tool.py,sha256=
|
|
14
|
-
gitcode_api/llm/mcp.py,sha256=
|
|
11
|
+
gitcode_api/version.txt,sha256=2ejoQpxqfQuWXk-sJqXv_3ED8FX6qYzOtb1HMf0kYDo,6
|
|
12
|
+
gitcode_api/llm/__init__.py,sha256=nCWs5jCnSxC9ILhiAh4vrNG0dVxkK3iqVz66c-0sE4I,1450
|
|
13
|
+
gitcode_api/llm/_tool.py,sha256=piKizg127X_n4j517d6leyWbDMBVVTL7WwSvP6EtufQ,16247
|
|
14
|
+
gitcode_api/llm/mcp.py,sha256=kaw5mnKfLExTPLY2y1tyGso0LKLAY7uY78kn4Fl3b-k,5730
|
|
15
15
|
gitcode_api/llm/openai.py,sha256=CcS3tFntzAuN2HMbbQDctb54AnasU3n3a1Jr9LWAHwM,1998
|
|
16
16
|
gitcode_api/resources/__init__.py,sha256=nsCKW0bFDZ5ombJZxLThmO82sOuF7o4OKUMRkAmwbwk,1725
|
|
17
17
|
gitcode_api/resources/_shared.py,sha256=7bCym8bIfs818SiYYrBGI7-ZtiYlxECSDG3RduInu10,5387
|
|
@@ -19,9 +19,9 @@ gitcode_api/resources/account.py,sha256=mnc2p7wI-nBnHFNdWPNiHfmZpT6d3RDQC777gewt
|
|
|
19
19
|
gitcode_api/resources/collaboration.py,sha256=8lyk78GTjVXddiE9fieutsMGovRjteGfTJcAhwLoR0M,101607
|
|
20
20
|
gitcode_api/resources/misc.py,sha256=guDwh4cxbTVsSa7EivaYM3bKMJ8_Op4KucGbKEoayKE,22412
|
|
21
21
|
gitcode_api/resources/repositories.py,sha256=EAK2znZhEsgVUu-NDEQslSEEYJzvb-kHuh4mW57y6sc,78178
|
|
22
|
-
gitcode_api-1.2.
|
|
23
|
-
gitcode_api-1.2.
|
|
24
|
-
gitcode_api-1.2.
|
|
25
|
-
gitcode_api-1.2.
|
|
26
|
-
gitcode_api-1.2.
|
|
27
|
-
gitcode_api-1.2.
|
|
22
|
+
gitcode_api-1.2.7.dist-info/licenses/LICENSE,sha256=gOACXuWhMu6PJKVLr9RQbxX3HULnZIGNXCaMFJIXhoA,1067
|
|
23
|
+
gitcode_api-1.2.7.dist-info/METADATA,sha256=bWfQFWXLXHJFpTqGPZxQRv35gjL41QV7J6ARBiRKvj0,20120
|
|
24
|
+
gitcode_api-1.2.7.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
25
|
+
gitcode_api-1.2.7.dist-info/entry_points.txt,sha256=dIPylJcgohIE2RRIlt3In2WzcwDK8TOdkL_ReKuij4o,53
|
|
26
|
+
gitcode_api-1.2.7.dist-info/top_level.txt,sha256=gIlg0ptyOUHJT64ajOjWIhRPYgIQnMIvnhhnesw9fxU,12
|
|
27
|
+
gitcode_api-1.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|