feat(tools): implement issue operations - Closes #3

Implement Gitea issue operations tools with the following features:
- gitea_list_issues: List issues with filters (state, labels, milestone)
- gitea_get_issue: Get single issue by number
- gitea_create_issue: Create new issue with title, body, labels, milestone
- gitea_update_issue: Update issue state, title, body, labels, assignees

Files added:
- src/gitea_mcp/tools/issues.py: Issue operation tool handlers

Files modified:
- src/gitea_mcp/server.py: Register issue tools in MCP server
- src/gitea_mcp/tools/__init__.py: Export issue tool functions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 15:17:40 -05:00
parent 1e0d896d87
commit 694406941c
3 changed files with 417 additions and 32 deletions

View File

@@ -9,6 +9,7 @@ from mcp.types import Tool, TextContent
from . import __version__
from .auth import AuthConfig
from .client import GiteaClient, GiteaClientError
from .tools import get_issue_tools, handle_issue_tool
# Global client instance
@@ -35,10 +36,13 @@ async def serve() -> None:
"""List available MCP tools.
Returns:
list: Available tools (placeholder for future implementation).
list: Available tools including issue operations.
"""
# Placeholder tools - will be implemented in issues #3, #4, #5
return [
# Get issue tools
tools = get_issue_tools()
# Placeholder for future tools (PR tools, etc.)
tools.extend([
Tool(
name="list_repositories",
description="List repositories in an organization (coming soon)",
@@ -53,32 +57,6 @@ async def serve() -> None:
"required": ["org"],
},
),
Tool(
name="create_issue",
description="Create a new issue in a repository (coming soon)",
inputSchema={
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "Repository owner",
},
"repo": {
"type": "string",
"description": "Repository name",
},
"title": {
"type": "string",
"description": "Issue title",
},
"body": {
"type": "string",
"description": "Issue body",
},
},
"required": ["owner", "repo", "title"],
},
),
Tool(
name="create_pull_request",
description="Create a new pull request (coming soon)",
@@ -109,7 +87,9 @@ async def serve() -> None:
"required": ["owner", "repo", "title", "head", "base"],
},
),
]
])
return tools
@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
@@ -122,11 +102,17 @@ async def serve() -> None:
Returns:
list: Tool response.
"""
# Placeholder implementation - actual tools will be implemented in future issues
# Handle issue tools
if name.startswith("gitea_") and any(
name.endswith(suffix) for suffix in ["_issues", "_issue"]
):
return await handle_issue_tool(name, arguments, gitea_client)
# Placeholder for other tools
return [
TextContent(
type="text",
text=f"Tool '{name}' is not yet implemented. Coming soon in issues #3, #4, #5.",
text=f"Tool '{name}' is not yet implemented.",
)
]