feat(C2.8): Add scrape_codebase MCP tool for local codebase analysis
- Add scrape_codebase_tool() to scraping_tools.py (67 lines) - Register tool in MCP server with @safe_tool_decorator - Add tool to FastMCP server imports and exports - Add 2 comprehensive tests for basic and advanced usage - Update MCP server tool count from 17 to 18 tools - Tool supports directory analysis with configurable depth - Features: language filtering, file patterns, API reference generation Closes #70 - C2.8 MCP Tool Integration complete Related: - Builds on C2.7 (codebase_scraper.py CLI tool) - Uses existing code_analyzer.py infrastructure - Follows same pattern as scrape_github and scrape_pdf tools Test coverage: - test_scrape_codebase_basic: Basic codebase analysis - test_scrape_codebase_with_options: Advanced options testing
This commit is contained in:
@@ -429,6 +429,38 @@ class TestScrapingTools:
|
||||
|
||||
assert isinstance(result, str)
|
||||
|
||||
async def test_scrape_codebase_basic(self, temp_dirs):
|
||||
"""Test basic codebase scraping."""
|
||||
# Create a dummy source directory
|
||||
src_dir = temp_dirs["output"] / "test_codebase"
|
||||
src_dir.mkdir()
|
||||
(src_dir / "test.py").write_text("def hello(): pass")
|
||||
|
||||
result = await server_fastmcp.scrape_codebase(
|
||||
directory=str(src_dir),
|
||||
output=str(temp_dirs["output"] / "codebase_analysis")
|
||||
)
|
||||
|
||||
assert isinstance(result, str)
|
||||
|
||||
async def test_scrape_codebase_with_options(self, temp_dirs):
|
||||
"""Test codebase scraping with various options."""
|
||||
# Create a dummy source directory
|
||||
src_dir = temp_dirs["output"] / "test_codebase2"
|
||||
src_dir.mkdir()
|
||||
(src_dir / "main.py").write_text("class Foo: pass")
|
||||
(src_dir / "utils.js").write_text("function bar() {}")
|
||||
|
||||
result = await server_fastmcp.scrape_codebase(
|
||||
directory=str(src_dir),
|
||||
depth="deep",
|
||||
languages="Python,JavaScript",
|
||||
file_patterns="*.py,*.js",
|
||||
build_api_reference=True
|
||||
)
|
||||
|
||||
assert isinstance(result, str)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# PACKAGING TOOLS TESTS (3 tools)
|
||||
|
||||
Reference in New Issue
Block a user