From b47353bfa3dc1c0f4353d1440ca323cbd9ee902e Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 5 May 2025 20:50:31 -0400 Subject: [PATCH] Update [ghstack-poisoned] --- codemcp/multi_entry.py | 103 ----------------------------------------- pyproject.toml | 5 -- 2 files changed, 108 deletions(-) delete mode 100644 codemcp/multi_entry.py diff --git a/codemcp/multi_entry.py b/codemcp/multi_entry.py deleted file mode 100644 index 89365e7..0000000 --- a/codemcp/multi_entry.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 -from mcp.server.fastmcp import Context, FastMCP - -from codemcp.tools.edit_file import edit_file_content -from codemcp.tools.grep import grep_files -from codemcp.tools.init_project import init_project -from codemcp.tools.ls import ls_directory -from codemcp.tools.read_file import read_file_content -from codemcp.tools.write_file import write_file_content - -mcp = FastMCP("codemcp_multi") - - -# Helper function to get a chat_id from a Context -def get_chat_id_from_context(ctx: Context) -> str: - # Generate a chat_id from the context - ctx_id = getattr(ctx, "id", None) - return f"multi-{ctx_id}" if ctx_id else "multi-default" - - -@mcp.tool() -async def read_file( - ctx: Context, file_path: str, offset: int | None = None, limit: int | None = None -) -> str: - # Get chat ID from context - chat_id = get_chat_id_from_context(ctx) - return await read_file_content(file_path, offset, limit, chat_id) - - -@mcp.tool() -async def write_file( - ctx: Context, file_path: str, content: str, description: str -) -> str: - # Get chat ID from context - chat_id = get_chat_id_from_context(ctx) - return await write_file_content(file_path, content, description, chat_id) - - -@mcp.tool() -async def edit_file( - ctx: Context, file_path: str, old_string: str, new_string: str, description: str -) -> str: - # Get chat ID from context - chat_id = get_chat_id_from_context(ctx) - return await edit_file_content( - file_path, old_string, new_string, None, description, chat_id - ) - - -@mcp.tool() -async def ls(ctx: Context, file_path: str) -> str: - # Get chat ID from context - chat_id = get_chat_id_from_context(ctx) - return await ls_directory(file_path, chat_id) - - -@mcp.tool() -async def grep( - ctx: Context, pattern: str, path: str | None = None, include: str | None = None -) -> str: - # Get chat ID from context - chat_id = get_chat_id_from_context(ctx) - result = await grep_files(pattern, path, include, chat_id) - return result.get( - "resultForAssistant", f"Found {result.get('numFiles', 0)} file(s)" - ) - - -@mcp.tool() -async def init_project_tool( - ctx: Context, - file_path: str, - user_prompt: str, - subject_line: str, - reuse_head_chat_id: bool = False, -) -> str: - # The init_project function actually doesn't accept a chat_id parameter - # It generates its own chat_id, so we don't pass it as an argument - return await init_project(file_path, user_prompt, subject_line, reuse_head_chat_id) - - -def main(): - # Set up a signal handler to exit immediately on Ctrl+C - import signal - import os - import logging - - def handle_exit(sig, frame): - logging.info( - "Received shutdown signal - exiting immediately without waiting for connections" - ) - os._exit(0) - - # Register for SIGINT (Ctrl+C) and SIGTERM - signal.signal(signal.SIGINT, handle_exit) - signal.signal(signal.SIGTERM, handle_exit) - - # The signal handler will force-exit the process when Ctrl+C is pressed - mcp.run() - - -if __name__ == "__main__": - main() diff --git a/pyproject.toml b/pyproject.toml index 23fcea1..6851976 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ dev = [ [project.scripts] codemcp = "codemcp:cli" -codemcp-multi = "codemcp.multi_entry:main" [build-system] requires = ["hatchling"] @@ -117,7 +116,3 @@ errorCodes = ["reportUnknownMemberType", "reportUnknownArgumentType", "reportUnk [[tool.pyright.ignoreExtraErrors]] path = "codemcp/config.py" errorCodes = ["reportUnknownVariableType"] - -[[tool.pyright.ignoreExtraErrors]] -path = "codemcp/multi_entry.py" -errorCodes = ["reportUnknownParameterType", "reportUnknownArgumentType", "reportMissingTypeArgument"]