Skip to main content

MCP Tools

The Constellation MCP Server employs a code mode implementation; exposing a single execute_code tool that executes AI-composed code with access to powerful API methods for querying your codebase knowledge.

Available Tools

Code Mode provides access to the following powerful tools organized by category:

CategoryToolsPurpose
DiscoverysearchSymbols, getSymbolDetailsFind and inspect code symbols
DependenciesgetDependencies, getDependents, findCircularDependenciesAnalyze code relationships
TracingtraceSymbolUsage, getCallGraphTrack symbol usage and calls
ImpactimpactAnalysis, findOrphanedCodeAssess change impact, find dead code
ArchitecturegetArchitectureOverviewHigh-level project overview

What is Code Mode?

Code Mode is a paradigm shift in how AI assistants interact with MCP servers. Instead of calling individual tools sequentially, your AI assistant writes code that can execute multiple operations in one call.

🐢 Traditional MCP (slow):

🏎️ Code Mode (fast):

This works very well because LLMs are trained on vast amounts of real-world code, making them exceptionally good at writing code. Code Mode leverages this strength for dramatically better performance and results.

Learn more about Code Mode →

How It Works

The Constellation MCP server exposes a single tool called execute_code. Your AI assistant writes JavaScript code that calls API methods to query your codebase.

For example, ask your Constellation-enabled AI coding assistant "What are the risks of updating the handleAuth method?", and it will likely compose code similar to the following and execute it with the Constellation MCP server:

const search = await api.searchSymbols({ query: 'handleAuth' });
const impact = await api.impactAnalysis({ symbolId: search.symbols[0].id });
return { search, impact };

Upon successful execution, the Constellation MCP server returns structured information to the AI assistant about the handleAuth method and any potential impact of modifying it.

Architecture

  1. AI writes code: Your assistant generates JavaScript based on your request
  2. Secure sandbox: Code executes in an isolated environment with only Constellation API access
  3. API execution: The api object in the JavaScript sandbox provides methods to query the project codebase knowledge graph
  4. Results returned: Structured data is returned to your AI assistant

The execute_code Tool

This is the only MCP tool exposed by the Constellation MCP server. Your AI assistant writes JavaScript code that gets executed in a secure sandbox.

Input Schema (from AI)

ParameterTypeRequiredDefaultDescription
codestringYes-JavaScript code to execute
timeoutnumberNo30000Max execution time (1000-60000 ms)

Output Format (from Constellation)

{
success: boolean; // Whether execution succeeded
result?: any; // The returned value from your code
logs?: string[]; // Console output captured during execution
executionTime: number; // Milliseconds taken to execute
error?: string; // Error message if execution failed
}

Secure JavaScript Sandbox

AI-provided code executes in a restricted environment:

  • Allowed: api.* methods, Promise, Array, Object, String, Number, Boolean, Date, JSON, Math, RegExp, Map, Set, console.log/error/warn
  • Blocked: require, import, fs, process, http, net, eval, Function, __proto__, etc.

Full Example

To demonstrate the power, flexibility, and efficiency of code mode MCP tools, consider the following an example of how AI could compose a code snippet for comprehensive symbol analysis for a UserService class.

const symbolName = "UserService";

// Find the symbol
const searchResult = await api.searchSymbols({
query: symbolName,
limit: 1
});

if (searchResult.symbols.length === 0) {
return { error: "Symbol not found: " + symbolName };
}

const symbol = searchResult.symbols[0];

// Parallel analysis of multiple aspects
const [details, usage, deps, dependents, impact] = await Promise.all([
api.getSymbolDetails({
symbolName: symbol.name,
filePath: symbol.filePath
}),
api.traceSymbolUsage({
symbolName: symbol.name,
filePath: symbol.filePath
}),
api.getDependencies({
filePath: symbol.filePath
}),
api.getDependents({
filePath: symbol.filePath
}),
api.impactAnalysis({
symbolName: symbol.name,
filePath: symbol.filePath
})
]);

// Calculate risk score based on usage and dependency counts
const usageCount = usage.directUsages.length;
const depsCount = deps.directDependencies.length;
const dependentCount = dependents.directDependents.length;

let riskScore = 0;
if (usageCount > 50) riskScore += 3;
else if (usageCount > 20) riskScore += 2;
else if (usageCount > 5) riskScore += 1;

if (dependentCount > 10) riskScore += 2;
if (depsCount > 20) riskScore += 1;

const riskLevel = riskScore >= 4 ? "HIGH" :
riskScore >= 2 ? "MEDIUM" : "LOW";

return {
symbol: symbol.name,
file: symbol.filePath,
usageCount,
dependencyCount: depsCount,
dependentCount,
riskLevel,
riskScore,
impactSummary: impact.summary,
recommendation: riskLevel === "HIGH"
? "Consider gradual refactoring with feature flags"
: "Safe to refactor directly"
};

Traditional individual MCP tools would require 6 distinct tool executions and then for the AI assistant to synthesize the results and perform the calculations for a comparable result. Yet, each time traditional tools run the AI assistant would return non-deterministic (inconsistent and sometimes inaccurate) results.