Interface Extractor¶
Extract public API surfaces from all modules without reading implementations. Answers: "What does each module expose?"
An AI agent uses this to understand module boundaries—what can be imported, called, or composed from each part of a project.
Usage¶
CLI¶
python interface_extractor.py <project_path>
python interface_extractor.py <project_path> --output interfaces.json
python interface_extractor.py src/core/ --markdown
python interface_extractor.py <project_path> --compact
MCP¶
Returns public API surfaces as JSON.
Example Output¶
Python Example¶
{
"summary": {
"total_modules": 24,
"modules_with_interfaces": 18,
"total_public_functions": 67,
"total_public_classes": 43
},
"modules": {
"src/core/engine.py": {
"module_name": "core.engine",
"docstring": "Core execution engine for processing tasks.",
"exports": ["Engine", "run", "configure"],
"classes": [
{
"name": "Engine",
"bases": [],
"docstring": "Main execution engine.",
"methods": [
{
"name": "__init__",
"signature": "(self, config: dict, timeout: int = 30) -> None",
"docstring": "Initialize the engine."
},
{
"name": "run",
"signature": "(self, input: str) -> bool",
"docstring": "Execute the engine on input."
},
{
"name": "async_process",
"signature": "async (self, data: list) -> list",
"docstring": "Process data asynchronously."
}
]
}
],
"functions": [
{
"name": "run",
"signature": "(config: dict) -> Engine",
"docstring": "Factory function to create and run engine."
},
{
"name": "configure",
"signature": "(settings: dict) -> None",
"docstring": "Configure the engine globally."
}
],
"types": [
{"name": "ExecutionResult", "definition": "TypedDict"}
]
},
"src/api/handler.py": {
"module_name": "api.handler",
"exports": ["RequestHandler", "handle_request"],
"classes": [
{
"name": "RequestHandler",
"bases": ["ABC"],
"methods": [
{
"name": "handle",
"signature": "(self, request: Request) -> Response"
},
{
"name": "validate",
"signature": "(self, request: Request) -> bool"
}
]
}
],
"functions": [
{
"name": "handle_request",
"signature": "(req: Request) -> Response"
}
]
}
}
}
JavaScript/TypeScript Example¶
{
"modules": {
"src/api/router.ts": {
"module_name": "api.router",
"exports": [
{
"name": "createRouter",
"type": "function",
"signature": "(config: RouterConfig) => Router"
},
{
"name": "Router",
"type": "class",
"signature": "class Router { route(...); handle(...); }"
},
{
"name": "RouterConfig",
"type": "interface",
"properties": [
{"name": "port", "type": "number"},
{"name": "ssl", "type": "boolean"}
]
}
]
},
"src/index.ts": {
"module_name": "index",
"exports": [
{"name": "createRouter", "type": "re-export"},
{"name": "Router", "type": "re-export"}
]
}
}
}
Supported Languages¶
- Python: Classes, functions, all declarations, type hints
- JavaScript/TypeScript: Exports, default exports, re-exports, interface signatures
- Rust: pub fn, pub struct, pub trait, pub use
- Go: Exported functions, structs, interfaces (capital letters)
- C#: public classes, methods, properties
Options¶
| Flag | Type | Default | Description |
|---|---|---|---|
project_path |
positional | required | Path to project root |
--output, -o |
string | stdout | Output file path |
--markdown, -m |
flag | false | Output as Markdown instead of JSON |
--compact, -c |
flag | false | Compact JSON (no indentation) |