Skip to content

Commit 80bd095

Browse files
committed
fix(server): restore files:// resource with url-decoding support
1 parent bc69e26 commit 80bd095

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/code_index_mcp/server.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from contextlib import asynccontextmanager
1717
from dataclasses import dataclass
1818
from typing import AsyncIterator, Dict, Any, List, Optional
19+
from urllib.parse import unquote
1920

2021
# Third-party imports
2122
from mcp.server.fastmcp import FastMCP, Context
@@ -124,6 +125,15 @@ async def indexer_lifespan(_server: FastMCP) -> AsyncIterator[CodeIndexerContext
124125
# Create the MCP server with lifespan manager
125126
mcp = FastMCP("CodeIndexer", lifespan=indexer_lifespan, dependencies=["pathlib"])
126127

128+
# ----- RESOURCES -----
129+
130+
@mcp.resource("files://{file_path}")
131+
def get_file_content(file_path: str) -> str:
132+
"""Get the content of a specific file."""
133+
decoded_path = unquote(file_path)
134+
ctx = mcp.get_context()
135+
return FileService(ctx).get_file_content(decoded_path)
136+
127137
# ----- TOOLS -----
128138

129139
@mcp.tool()

0 commit comments

Comments
 (0)