Skip to content

Commit 24285ed

Browse files
committed
refactor(server): remove unused structure://project resource and MCP prompts
- delete resource registration in src/code_index_mcp/server.py - remove ProjectManagementService.get_project_structure; drop unused json import - remove analyze_code, code_search, set_project prompts; drop unused mcp.types import
1 parent 0c20349 commit 24285ed

File tree

2 files changed

+3
-101
lines changed

2 files changed

+3
-101
lines changed

src/code_index_mcp/server.py

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from typing import AsyncIterator, Dict, Any, List
1717

1818
# Third-party imports
19-
from mcp import types
2019
from mcp.server.fastmcp import FastMCP, Context
2120

2221
# Local imports
@@ -106,13 +105,7 @@ def get_file_content(file_path: str) -> str:
106105
# Use FileService for simple file reading - this is appropriate for a resource
107106
return FileService(ctx).get_file_content(file_path)
108107

109-
@mcp.resource("structure://project")
110-
@handle_mcp_resource_errors
111-
def get_project_structure() -> str:
112-
"""Get the structure of the project as a JSON tree."""
113-
ctx = mcp.get_context()
114-
return ProjectManagementService(ctx).get_project_structure()
115-
108+
# Removed: structure://project resource - not necessary for most workflows
116109
# Removed: settings://stats resource - this information is available via get_settings_info() tool
117110
# and is more of a debugging/technical detail rather than context AI needs
118111

@@ -305,62 +298,7 @@ def configure_file_watcher(
305298
return SystemManagementService(ctx).configure_file_watcher(enabled, debounce_seconds, additional_exclude_patterns)
306299

307300
# ----- PROMPTS -----
308-
309-
@mcp.prompt()
310-
def analyze_code(file_path: str = "", query: str = "") -> list[types.PromptMessage]:
311-
"""Prompt for analyzing code in the project."""
312-
messages = [
313-
types.PromptMessage(role="user", content=types.TextContent(type="text", text=f"""I need you to analyze some code from my project.
314-
315-
{f'Please analyze the file: {file_path}' if file_path else ''}
316-
{f'I want to understand: {query}' if query else ''}
317-
318-
First, let me give you some context about the project structure. Then, I'll provide the code to analyze.
319-
""")),
320-
types.PromptMessage(
321-
role="assistant",
322-
content=types.TextContent(
323-
type="text",
324-
text="I'll help you analyze the code. Let me first examine the project structure to get a better understanding of the codebase."
325-
)
326-
)
327-
]
328-
return messages
329-
330-
@mcp.prompt()
331-
def code_search(query: str = "") -> types.TextContent:
332-
"""Prompt for searching code in the project."""
333-
search_text = "\"query\"" if not query else f"\"{query}\""
334-
return types.TextContent(
335-
type="text",
336-
text=f"""I need to search through my codebase for {search_text}.
337-
338-
Please help me find all occurrences of this query and explain what each match means in its context.
339-
Focus on the most relevant files and provide a brief explanation of how each match is used in the code.
340-
341-
If there are too many results, prioritize the most important ones and summarize the patterns you see."""
342-
)
343-
344-
@mcp.prompt()
345-
def set_project() -> list[types.PromptMessage]:
346-
"""Prompt for setting the project path."""
347-
messages = [
348-
types.PromptMessage(role="user", content=types.TextContent(type="text", text="""
349-
I need to analyze code from a project, but I haven't set the project path yet. Please help me set up the project path and index the code.
350-
351-
First, I need to specify which project directory to analyze.
352-
""")),
353-
types.PromptMessage(role="assistant", content=types.TextContent(type="text", text="""
354-
Before I can help you analyze any code, we need to set up the project path. This is a required first step.
355-
356-
Please provide the full path to your project folder. For example:
357-
- Windows: "C:/Users/username/projects/my-project"
358-
- macOS/Linux: "/home/username/projects/my-project"
359-
360-
Once you provide the path, I'll use the `set_project_path` tool to configure the code analyzer to work with your project.
361-
"""))
362-
]
363-
return messages
301+
# Removed: analyze_code, code_search, set_project prompts
364302

365303
def main():
366304
"""Main function to run the MCP server."""

src/code_index_mcp/services/project_management_service.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This service handles the business logic for project initialization, configuration,
55
and lifecycle management using the new JSON-based indexing system.
66
"""
7-
import json
87
import logging
98
from typing import Dict, Any
109
from dataclasses import dataclass
@@ -409,39 +408,4 @@ def get_project_config(self) -> str:
409408

410409
return ResponseFormatter.config_response(config_data)
411410

412-
def get_project_structure(self) -> str:
413-
"""
414-
Get the project directory structure for MCP resource.
415-
416-
Returns:
417-
JSON formatted project structure
418-
"""
419-
420-
# Check if project is configured
421-
if not self.helper.base_path:
422-
structure_data = {
423-
"status": "not_configured",
424-
"message": ("Project path not set. Please use set_project_path "
425-
"to set a project directory first.")
426-
}
427-
return json.dumps(structure_data, indent=2)
428-
429-
# Check if we have index cache with directory tree
430-
if (hasattr(self.ctx.request_context.lifespan_context, 'index_cache') and
431-
self.ctx.request_context.lifespan_context.index_cache and
432-
'directory_tree' in self.ctx.request_context.lifespan_context.index_cache):
433-
434-
directory_tree = self.ctx.request_context.lifespan_context.index_cache['directory_tree']
435-
return json.dumps(directory_tree, indent=2)
436-
437-
# If no directory tree available, try to build basic structure
438-
try:
439-
# Use config tool to get basic project structure
440-
basic_structure = self._config_tool.get_basic_project_structure(self.helper.base_path)
441-
return json.dumps(basic_structure, indent=2)
442-
except Exception as e:
443-
error_data = {
444-
"error": f"Unable to get project structure: {e}",
445-
"status": "error"
446-
}
447-
return json.dumps(error_data, indent=2)
411+
# Removed: get_project_structure; the project structure resource is deprecated

0 commit comments

Comments
 (0)