MCP API Reference
Complete API documentation for the Model Context Protocol server providing AI-powered code search and project management.
Endpoint
The server speaks MCP over the SSE transport. Connect MCP clients to the host-facing endpoint:
http://localhost:6765/sse6765 is the host port (MCP_SERVER_PORT in .env.defaults); it maps to the container's internal port 8765, which is never used from the host. The only plain-HTTP route the server exposes is /health (see Health Check). Tools are invoked through the MCP/SSE protocol — there are no REST tool/metrics endpoints.
Authentication
Currently no authentication required (local development only).
Tools
search_codebase
Semantic search across indexed repositories.
Parameters:
{
query: string; // Search query
project?: string; // "platform" | "framework" | project name; omit to search all
file_types?: string | string[]; // Comma-separated string ("php,js") or list
component_type?: string; // Filter by type (function, class, hook, ...)
exclude_patterns?: string[]; // Path substrings to exclude (e.g. ["vendor/", "tests/"])
include_context?: boolean; // Include surrounding code lines (default: false)
context_lines?: number; // Context lines before/after, 1-20 (default: 5)
limit?: number; // Max results (default: 20)
}Response: An object with status, count, collection, query, search_type, execution_time_ms, and a results array. (When project is omitted, the response is a cross-collection search with collections_searched and each result tagged with its collection.)
{
"status": "success",
"count": 1,
"collection": "project_my_site",
"query": "email validation",
"search_type": "vector",
"execution_time_ms": 42.7,
"results": [
{
"file_path": "wp-content/themes/custom/functions.php",
"component_type": "function",
"name": "custom_register_post_types",
"line_number": 45,
"language": "php",
"content": "function custom_register_post_types() {...}",
"repository": "my-site",
"score": 0.89
}
]
}Example:
from mcp import Client
client = Client("http://localhost:6765/sse")
results = client.call_tool("search_codebase", {
"query": "email validation",
"file_types": "php,js",
"exclude_patterns": ["tests/"],
"limit": 10
})search_functions
Find functions by name across codebase.
Parameters:
{
function_name: string; // Function name (partial match)
project?: string; // Optional project filter
language?: string; // Language filter (default: "php")
fuzzy_match?: boolean; // Match across naming conventions (default: true)
}Response:
[
{
"function_name": "validate_email",
"file_path": "inc/utilities/validators.php",
"signature": "validate_email($email, $strict = false)",
"line_start": 12,
"line_end": 20,
"docblock": "/**\n * Validate email address\n * @param string $email\n */"
}
]search_classes
Find class definitions by name. Supports fuzzy matching across naming conventions. (There is no language parameter.)
Parameters:
{
class_name: string; // Class name (partial match)
project?: string; // Optional project filter
fuzzy_match?: boolean; // Match across naming conventions (default: true)
}Response:
[
{
"class_name": "CustomPostType",
"file_path": "inc/post-types/base.php",
"namespace": "WDG\\PostTypes",
"methods": ["__construct", "register", "get_labels"],
"extends": null,
"implements": []
}
]search_wordpress_hooks
Find WordPress hook registrations — add_action() and add_filter() calls. To find where hooks are invoked (do_action() / apply_filters()), use search_hook_invocations.
Parameters:
{
hook_name: string; // Hook name (partial match)
hook_type?: "action" | "filter"; // Optional registration type
project?: string; // Optional project filter
}Response:
[
{
"hook_name": "init",
"hook_type": "add_action",
"callback": "custom_init_function",
"priority": 10,
"accepted_args": 1,
"file_path": "functions.php",
"line_number": 45
}
]search_hook_invocations
Find where WordPress hooks are invoked — do_action() and apply_filters() calls (not registrations).
Parameters:
{
hook_name: string; // Hook name (partial match)
invocation_type?: "action" | "filter"; // "action" = do_action, "filter" = apply_filters
project?: string; // Optional project filter
}search_all_collections
Search across all indexed collections at once (framework, platform, and every project).
Parameters:
{
query: string;
file_types?: string | string[];
component_type?: string;
limit?: number; // Max results across all collections (default: 20)
}search_code_patterns
Find code by structural relationship.
Parameters:
{
pattern_type: "extends" | "implements" | "calls_function";
pattern_value: string; // Class name, interface, or function to match
project?: string;
limit?: number; // Default: 20
}search_function_callers
Find what functions call a given function (reads indexed calls metadata).
Parameters:
{
function_name: string;
project?: string;
limit?: number; // Default: 20
}search_function_calls
Find what functions a given function calls.
Parameters:
{
function_name: string;
project?: string;
}search_acf_fields
Find Advanced Custom Fields (ACF) field and field-group definitions.
Parameters:
{
field_name?: string;
field_type?: string; // e.g. "text", "image", "repeater"
group_name?: string;
project?: string;
}search_acf_field_usages
Find where ACF fields are used in code (get_field(), get_sub_field(), the_field(), have_rows()).
Parameters:
{
field_name: string;
project?: string;
}get_block_schema
Get the full parsed block.json schema for a Wikit block.
Parameters:
{
block_name: string; // Full or partial block name (e.g. "wdg/hero")
project?: string;
}batch_search
Run multiple searches in a single call (parallel by default).
Parameters:
{
searches: Array<{ // Each entry is a search config
id?: string;
query: string;
project?: string;
file_types?: string | string[];
component_type?: string;
exclude_patterns?: string[];
limit?: number;
}>;
parallel?: boolean; // Default: true
fail_fast?: boolean; // Default: false
}Maximum 10 concurrent searches per call.
Example:
client.call_tool("batch_search", {
"searches": [
{"id": "hooks", "query": "add_action", "file_types": "php"},
{"id": "blocks", "query": "registerBlockType", "file_types": "js"}
],
"parallel": True,
"fail_fast": False
})save_search / get_saved_search / list_saved_searches / delete_saved_search
Persist and recall labeled searches.
save_search({ label: string; query: string; filters?: object; description?: string })
get_saved_search({ label: string; execute?: boolean }) // execute runs the search
list_saved_searches({ sort_by?: "last_used" | "use_count" | "label" | "created_at"; limit?: number })
delete_saved_search({ label: string })get_search_history
Retrieve recent search history with result counts and timing.
Parameters:
{
limit?: number; // Default: 50
query_filter?: string; // Optional substring filter on past queries
}search_wikit_blocks
Search Wikit Gutenberg blocks.
Parameters:
{
block_name?: string; // Optional block name filter
}Response:
[
{
"name": "wdg/hero",
"title": "Hero Section",
"category": "wdg-layout",
"description": "Full-width hero with background image/video",
"keywords": ["hero", "banner", "header"],
"attributes": {
"backgroundType": {"type": "string", "default": "image"},
"overlayOpacity": {"type": "number", "default": 0.5}
},
"example": {
"attributes": {...}
}
}
]get_project_info
Get project details and indexing status.
Parameters:
{
project_name: string; // Project name
}Response:
{
"name": "my-site",
"status": "running",
"php_version": "8.2",
"url": "https://my-site.localhost:6443",
"database": {
"name": "wp_my_site",
"size": "45.2 MB"
},
"collection": "project_my_site",
"vectors": 1450,
"last_indexed": "2024-10-14T10:30:00Z",
"repositories": [
{
"name": "my-site",
"branch": "main",
"last_commit": "abc123",
"commit_date": "2024-10-14T09:00:00Z"
}
]
}list_collections
List all vector database collections.
Parameters: None
Response:
{
"collections": [
{
"name": "wdg_framework",
"vectors_count": 15234,
"indexed_files": 5000,
"last_updated": "2024-10-14T09:15:00Z"
},
{
"name": "project_my_site",
"vectors_count": 1450,
"indexed_files": 500,
"last_updated": "2024-10-14T10:30:00Z"
}
],
"total_vectors": 16684,
"total_size": "52.9 MB"
}search_recent_changes
Get recently indexed code.
Parameters:
{
project?: string; // Optional project filter
limit?: number; // Max results (default: 10)
}Response:
[
{
"file_path": "inc/utilities/helpers.php",
"component_name": "format_phone_number",
"component_type": "function",
"indexed_at": "2024-10-14T10:30:00Z",
"commit_hash": "abc123",
"author": "John Doe"
}
]wordpress_docs
Search WordPress core documentation.
Parameters:
{
query: string; // Search query
type?: string; // Type: all, function, hook, class, method
get_details?: boolean; // Fetch full documentation
limit?: number; // Max results (default: 5)
}Response:
{
"results": [
{
"name": "register_post_type",
"type": "function",
"description": "Registers a post type",
"url": "https://developer.wordpress.org/reference/functions/register_post_type/"
}
],
"details": {
"signature": "register_post_type( $post_type, $args )",
"parameters": [...],
"return": "WP_Post_Type|WP_Error",
"source": "wp-includes/post.php"
}
}HTTP Endpoints
The server exposes exactly one plain-HTTP route. All tool discovery and invocation happens over the MCP/SSE protocol at /sse — there are no REST /tools or /metrics endpoints and no WebSocket interface.
Health Check
GET /healthResponse:
{
"status": "ok",
"version": "0.1.0"
}The version field is read from the platform VERSION file, falling back to "unknown" if it cannot be read. The endpoint always returns HTTP 200 when the server is alive — useful for Docker health checks, load balancers, and wdg doctor.
Error Handling
Error Response Format
{
"error": {
"code": "COLLECTION_NOT_FOUND",
"message": "Collection 'project_invalid' does not exist",
"details": {
"collection": "project_invalid",
"available_collections": ["project_my_site", "wdg_framework"]
}
}
}Error Codes
| Code | Description |
|---|---|
INVALID_PARAMETERS | Missing or invalid parameters |
COLLECTION_NOT_FOUND | Requested collection doesn't exist |
VECTOR_DB_ERROR | Qdrant database error |
INDEXING_ERROR | Error during indexing process |
INTERNAL_ERROR | Server error |
Rate Limiting
Currently no rate limiting (local development).
For production deployments:
- 100 requests per minute per client
- Burst allowance: 20 requests
Client Libraries
Python
from wdg_mcp import Client
client = Client("http://localhost:6765/sse")
# Search code
results = client.search_codebase(
query="email validation",
project="my-site",
limit=10
)
# Get project info
info = client.get_project_info("my-site")JavaScript/TypeScript
import { MCPClient } from '@wdg/mcp-client';
const client = new MCPClient('http://localhost:6765/sse');
// Search code
const results = await client.searchCodebase({
query: 'email validation',
project: 'my-site',
limit: 10
});
// Get project info
const info = await client.getProjectInfo('my-site');Integration Examples
Claude Desktop
{
"mcpServers": {
"wdg-local": {
"url": "http://localhost:6765/sse"
}
}
}Cursor IDE
{
"servers": {
"wdg-local": {
"url": "http://localhost:6765/sse",
"name": "WDG AI Dev Environment"
}
}
}See Also: