gitcode_api.llm
LLM tool adapters for the GitCode SDK.
- class GitCodeOpenAITool(async_mode: bool | None = None, **kwargs)
Bases:
GitCodeLLMToolOpenAI-compatible callable tool for invoking GitCode SDK resources.
- Parameters:
async_mode – When true, calling the instance returns the async tool coroutine.
kwargs – Forwarded to
gitcode_api.llm.GitCodeLLMTool.{"async": True}is also accepted for frameworks that construct tools from dictionaries.
Create an OpenAI tool wrapper.
- property tool: Dict[str, Any]
Return this tool in OpenAI Chat Completions tool format.
- to_dict() Dict[str, Any]
Return this tool in OpenAI Chat Completions tool format.
- class GitCodeMCP(name: str = 'GitCode API', tool: GitCodeLLMTool | None = None, **kwargs: Any)
Bases:
objectSmall FastMCP server wrapper exposing the GitCode API tool.
- Parameters:
name – MCP server name.
tool – Optional preconfigured shared GitCode LLM tool.
kwargs – Forwarded to
fastmcp.FastMCP. Ifinstructionsis omitted, a default overview of the tool (parameters, byte encoding, and validop_typevalues) is supplied.
Create a FastMCP server and register the GitCode API tool.
- create_mcp_gitcode_api_tool(tool: GitCodeLLMTool | None = None) Callable
Return the async callable that can be registered with an MCP server.
- Parameters:
tool – Optional preconfigured shared GitCode LLM tool.
- Returns:
Async callable using the standard GitCode tool parameters.
- create_mcp_server(name: str = 'GitCode API', tool: GitCodeLLMTool | None = None, **kwargs: Any) FastMCP
Create a FastMCP server with the GitCode API tool already registered.
- Parameters:
name – MCP server display name.
tool – Optional preconfigured
GitCodeLLMTool.kwargs – Forwarded to
GitCodeMCPand then tofastmcp.FastMCP(for exampleinstructions=to override the default server instructions).
- Returns:
Configured
FastMCPinstance withgitcode_api_toolregistered.
- register_mcp_gitcode_api_tool(mcp: FastMCP | Any, tool: GitCodeLLMTool | None = None) Tool
Register the GitCode API tool with an existing FastMCP-compatible server.
- Parameters:
mcp – FastMCP server instance.
tool – Optional preconfigured shared GitCode LLM tool.
- Returns:
The registered tool callable.
- register_mcp_help_resources(mcp: FastMCP | Any) None
Register optional MCP resources that mirror
gitcode_api_toolhelp text.Registers:
gitcode-api://help— markdown index of per-op_typeURIs.gitcode-api://help/{op_type}— plain-text method list for one resource.
No-op when
mcpdoes not expose FastMCP’sresourcedecorator.- Parameters:
mcp – FastMCP server instance (or compatible object).