Server Tools¶
These tools power the MCP server endpoints.
MCP server¶
mcp_zen_of_languages.server
¶
MCP server exposing zen-of-languages analysis tools over the Model Context Protocol.
This module is the public surface of the zen analysis server. Every function
decorated with @mcp.tool becomes an MCP tool that IDE assistants and
automation agents can invoke. The module-level CONFIG singleton, loaded
once from zen-config.yaml via
load_config, governs default
thresholds, language lists, and pipeline overrides for the entire session.
Tool registration follows the FastMCP decorator pattern:
@mcp.tool(name="analyze_zen_violations", tags={"analysis", "zen", "snippet"})
async def analyze_zen_violations(code: str, language: str) -> AnalysisResult: ...
The tools are grouped into four families:
- Analysis — snippet and repository-level violation detection.
- Reporting — prompt generation, agent task lists, and markdown reports.
- Configuration — runtime override management and introspection.
- Onboarding — guided setup for new projects adopting zen analysis.
Note
Runtime overrides set via set_config_override are stored in the
module-level _runtime_overrides dict and persist only for the
current server session.
Classes¶
LanguageCoverage
¶
Bases: BaseModel
Per-language counts exposed by zen://languages resource.
LanguagesResource
¶
Bases: BaseModel
Container model for the zen://languages MCP resource.
ConfigOverride
¶
Bases: BaseModel
Session-scoped override for a single language's analysis thresholds.
When an MCP client calls set_config_override, the supplied values
are captured in a ConfigOverride instance and stored in the
module-level _runtime_overrides dict, keyed by language. Only
non-None fields are considered active — omitted fields leave the
corresponding zen-config.yaml default in effect.
Note
Overrides do not persist across server restarts. Call
clear_config_overrides to reset mid-session.
ConfigStatus
¶
Bases: BaseModel
Read-only snapshot of the server's current configuration state.
Returned by get_config, set_config_override, and
clear_config_overrides so callers can confirm the effective
settings after every mutation. The overrides_applied field
shows only the non-default values injected during the current session.
OnboardingStep
¶
Bases: BaseModel
A single instruction in the guided onboarding sequence.
Each step pairs a human-readable title and description with an
action key that MCP clients can use to trigger the corresponding
operation programmatically, and an optional example showing
concrete invocation syntax.
OnboardingGuide
¶
Bases: BaseModel
Complete onboarding payload returned by onboard_project.
Bundles an ordered list of OnboardingStep entries with a
recommended_config dict that reflects the thresholds appropriate
for the caller's chosen strictness profile. MCP clients can render
the steps as an interactive wizard or apply recommended_config
directly to zen-config.yaml.
Functions¶
main
¶
Start the FastMCP server with stdio transport.
This mirrors mcp_zen_of_languages.__main__.main so packaging can expose
a dedicated mcp-zen-of-languages-server console script without adding a
separate runtime path.
Source code in src/mcp_zen_of_languages/server.py
config_resource
¶
Return current configuration status as a read-only MCP resource.
Source code in src/mcp_zen_of_languages/server.py
rules_resource
¶
Return canonical zen principles for the requested language key.
Source code in src/mcp_zen_of_languages/server.py
languages_resource
¶
Return supported languages with principle and detector counts.
Source code in src/mcp_zen_of_languages/server.py
remediation_prompt
¶
Build a typed remediation prompt template for MCP clients.
Source code in src/mcp_zen_of_languages/server.py
detect_languages
async
¶
Return the language identifiers listed in the active zen-config.yaml.
Unlike heuristic language-detection libraries, this tool does not
scan file extensions or parse shebangs. It simply reflects the
languages key from the configuration that CONFIG loaded at
server startup, giving callers a predictable, deterministic list they
can iterate over when orchestrating multi-language analysis runs.
| PARAMETER | DESCRIPTION |
|---|---|
repo_path
|
Workspace root passed by the MCP client — reserved for future per-repo config resolution but currently unused.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LanguagesResult
|
LanguagesResult wrapping the list of language strings declared in
TYPE:
|
LanguagesResult
|
|
Example
See Also
get_supported_languages:
Lists languages that have registered detectors, rather than
configured languages.
Source code in src/mcp_zen_of_languages/server.py
analyze_zen_violations
async
¶
analyze_zen_violations(
code,
language,
severity_threshold=None,
perspective=PerspectiveMode.ALL,
project_as=None,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Run v1.0 snippet analysis.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
Source code to analyse.
TYPE:
|
language
|
Programming language identifier.
TYPE:
|
severity_threshold
|
Minimum severity to include. Default to None.
TYPE:
|
perspective
|
Requested analysis perspective. Default to
TYPE:
|
project_as
|
Projection-family target when
TYPE:
|
enable_external_tools
|
Opt-in execution of external linters. Default to False.
TYPE:
|
allow_temporary_runners
|
Allow temporary tool runners (e.g. npx/uvx). Default to False.
TYPE:
|
Source code in src/mcp_zen_of_languages/server.py
analyze_zen_violations_v2
async
¶
analyze_zen_violations_v2(
code,
language,
severity_threshold=None,
perspective=PerspectiveMode.ALL,
project_as=None,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Run v2.0 snippet analysis with non-empty code validation.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
Source code to analyse.
TYPE:
|
language
|
Programming language identifier.
TYPE:
|
severity_threshold
|
Severity threshold. Default to None.
TYPE:
|
perspective
|
Requested analysis perspective. Default to
TYPE:
|
project_as
|
Projection-family target when
TYPE:
|
enable_external_tools
|
Enable external tools. Default to False.
TYPE:
|
allow_temporary_runners
|
Allow temporary runners. Default to False.
TYPE:
|
Source code in src/mcp_zen_of_languages/server.py
generate_prompts_tool
async
¶
generate_prompts_tool(
code,
language,
perspective=PerspectiveMode.ALL,
project_as=None,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Generate remediation prompts for v1.0 prompt generation.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
Source code to analyse.
TYPE:
|
language
|
Programming language identifier.
TYPE:
|
perspective
|
Requested analysis perspective. Default to
TYPE:
|
project_as
|
Projection-family target when
TYPE:
|
enable_external_tools
|
Enable external tools. Default to False.
TYPE:
|
allow_temporary_runners
|
Allow temporary runners. Default to False.
TYPE:
|
Source code in src/mcp_zen_of_languages/server.py
generate_prompts_tool_v2
async
¶
generate_prompts_tool_v2(
code,
language,
perspective=PerspectiveMode.ALL,
project_as=None,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Generate remediation prompts for v2.0 prompt generation.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
Source code to analyse.
TYPE:
|
language
|
Programming language identifier.
TYPE:
|
perspective
|
Requested analysis perspective. Default to
TYPE:
|
project_as
|
Projection-family target when
TYPE:
|
enable_external_tools
|
Enable external tools. Default to False.
TYPE:
|
allow_temporary_runners
|
Allow temporary runners. Default to False.
TYPE:
|
Source code in src/mcp_zen_of_languages/server.py
analyze_repository
async
¶
analyze_repository(
repo_path,
languages=None,
max_files=100,
ctx=None,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Analyse every eligible file in a repository and return per-file results.
This is the public MCP tool that wraps
_analyze_repository_internal. It exists as a thin async façade so
that the internal helper can also be called from non-tool code paths
(such as generate_agent_tasks_tool) without duplicating parameter
validation or the @mcp.tool decorator.
| PARAMETER | DESCRIPTION |
|---|---|
repo_path
|
Absolute path to the repository root. The MCP client typically resolves this from the active workspace.
TYPE:
|
languages
|
Restrict analysis to specific
language identifiers. Defaults to
TYPE:
|
max_files
|
Per-language cap on the number of files to analyse, protecting against excessive runtime on monorepos. Default to 100.
TYPE:
|
ctx
|
Optional FastMCP context for progress and log updates during repository analysis. Default to None.
TYPE:
|
enable_external_tools
|
Opt-in execution of allow-listed external tools while analyzing files. Default to False.
TYPE:
|
allow_temporary_runners
|
Permit temporary-runner fallback strategies for external tools. Default to False.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RepositoryAnalysis]
|
list[RepositoryAnalysis]: List of |
list[RepositoryAnalysis]
|
and language with its |
Example
See Also
generate_agent_tasks_tool:
Builds actionable remediation tasks from repository analysis.
Source code in src/mcp_zen_of_languages/server.py
analyze_batch
async
¶
analyze_batch(
path,
language,
cursor=None,
max_tokens=8000,
max_files=100,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Analyse a repository and return one token-budgeted page of violations.
This tool is explicitly designed for LLM agent workflows where the full violation list would exceed the model's context window. It analyses the repository, sorts violations globally by severity (highest first), and returns only as many as fit within max_tokens. The opaque cursor field in the response encodes the resume position; pass it back unchanged on the next call to advance to the next page.
Design principles:
- Stateless — the cursor encodes the exact position in the sorted violation list; no server-side session state is required.
- Token-budget aware — the response is trimmed so that the serialised payload stays within max_tokens.
- Priority ordering — highest-severity violations are surfaced first across all pages.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Absolute or relative path to the repository root.
TYPE:
|
language
|
Language identifier to restrict analysis (e.g.
TYPE:
|
cursor
|
Opaque continuation token from a previous
call. Omit or pass
TYPE:
|
max_tokens
|
Approximate token budget for the
TYPE:
|
max_files
|
Cap on the number of files to analyse. Default to 100.
TYPE:
|
enable_external_tools
|
Opt-in execution of external linters. Default to False.
TYPE:
|
allow_temporary_runners
|
Permit temporary-runner strategies. Default to False.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BatchPage
|
A page carrying the token-budgeted violations, a continuation
TYPE:
|
BatchPage
|
cursor ( |
BatchPage
|
count metadata. |
Example
See Also
analyze_batch_summary:
Returns a compact health-score overview that always fits in one
context window.
analyze_repository:
Full (unpaginated) repository analysis for non-LLM consumers.
Source code in src/mcp_zen_of_languages/server.py
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 | |
analyze_batch_summary
async
¶
analyze_batch_summary(
path,
language,
max_files=100,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Return a compact health overview for a repository — always one page.
Unlike analyze_batch, which paginates a potentially large violation
list, this tool summarises the entire repository in a single response.
It is designed to fit comfortably inside any LLM context window so that
an agent can assess project health and identify where to focus before
deciding whether to call analyze_batch for deeper detail.
The returned health_score is the repository's average overall_score
expressed on a 0-100 scale (higher is better). The hotspots list
contains the five files with the highest violation count, ordered by
descending total violations.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Absolute or relative path to the repository root.
TYPE:
|
language
|
Language identifier to restrict analysis (e.g.
TYPE:
|
max_files
|
Cap on the number of files to analyse. Default to 100.
TYPE:
|
enable_external_tools
|
Opt-in execution of external linters. Default to False.
TYPE:
|
allow_temporary_runners
|
Permit temporary-runner strategies. Default to False.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BatchSummary
|
Compact summary with
TYPE:
|
BatchSummary
|
up to five |
Example
See Also
analyze_batch:
Full paginated violation detail for LLM agents.
analyze_repository:
Complete unpaginated results for non-LLM consumers.
Source code in src/mcp_zen_of_languages/server.py
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | |
analyze_batch_auto
async
¶
analyze_batch_auto(
path,
language,
cursor=None,
max_tokens=8000,
max_files=100,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Analyse a repository, routing automatically between full and paginated mode.
This tool eliminates the need to choose between analyze_repository
(full, unbounded) and analyze_batch (always paginated). It analyses
the repository once, then decides:
- If all violations fit within max_tokens: returns them all in a single
page (
has_more=False,cursor=None). - If violations exceed max_tokens: returns the first token-budgeted page
with a continuation cursor (
has_more=True).
Cursor continuation is handled identically to analyze_batch — pass the
opaque cursor from the previous response unchanged.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Absolute or relative path to the repository root.
TYPE:
|
language
|
Language identifier to restrict analysis (e.g.
TYPE:
|
cursor
|
Opaque continuation token from a previous
call. Omit or pass
TYPE:
|
max_tokens
|
Approximate token budget for the
TYPE:
|
max_files
|
Cap on the number of files to analyse. Default to 100.
TYPE:
|
enable_external_tools
|
Opt-in execution of external linters. Default to False.
TYPE:
|
allow_temporary_runners
|
Permit temporary-runner strategies. Default to False.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BatchPage
|
A page with
TYPE:
|
BatchPage
|
or a page with a continuation cursor when more pages remain. |
Example
See Also
analyze_batch:
Always-paginated variant with explicit cursor management.
analyze_batch_summary:
Compact overview (health score + hotspots) to decide if pagination is needed.
Source code in src/mcp_zen_of_languages/server.py
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 | |
generate_agent_tasks_tool
async
¶
generate_agent_tasks_tool(
repo_path,
languages=None,
min_severity=5,
*,
enable_external_tools=False,
allow_temporary_runners=False,
)
Convert repository-level violations into prioritised remediation tasks.
Agent workflows need structured, machine-readable work items — not
prose reports. This tool analyses the repository via
_analyze_repository_internal, extracts every violation whose
severity meets min_severity, and transforms them into an
AgentTaskList ordered by priority. Each task carries the file
path, rule identifier, and a concise action description an automated
agent can execute without further context.
| PARAMETER | DESCRIPTION |
|---|---|
repo_path
|
Absolute path to the repository to scan. All eligible source files are discovered recursively.
TYPE:
|
languages
|
Restrict scanning to these languages. Omit to analyse only Python files by default. Default to None.
TYPE:
|
min_severity
|
Severity floor (1-10 scale). Violations below this threshold are excluded from the task list. Default to 5.
TYPE:
|
enable_external_tools
|
Opt-in execution of allow-listed external tools while gathering repository analysis. Default to False.
TYPE:
|
allow_temporary_runners
|
Permit temporary-runner fallback strategies for external tools. Default to False.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AgentTaskList
|
AgentTaskList containing prioritised tasks ready for automated
TYPE:
|
AgentTaskList
|
remediation, sorted from highest to lowest severity. |
See Also
analyze_repository:
Retrieves the raw per-file results that feed task generation.
generate_prompts_tool:
Provides human-readable remediation text rather than
structured tasks.
Source code in src/mcp_zen_of_languages/server.py
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 | |
check_architectural_patterns
async
¶
Scan a code snippet for recognised architectural patterns.
Architectural pattern detection is not implemented yet.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
Source fragment to inspect for structural patterns.
TYPE:
|
language
|
Language identifier guiding which pattern
recognisers to apply (e.g.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
NotImplementedError
|
Always raised until pattern detection support is implemented. |
Source code in src/mcp_zen_of_languages/server.py
generate_report_tool
async
¶
generate_report_tool(
target_path,
language=None,
perspective=PerspectiveMode.ALL,
project_as=None,
*,
include_prompts=False,
include_analysis=True,
include_gaps=True,
ctx=None,
)
Produce a structured markdown report combining analysis, gaps, and prompts.
Reports are the highest-level output the server offers. They stitch
together violation analysis, coverage-gap summaries, and optional
remediation prompts into a single ReportOutput whose markdown
field is ready for rendering and whose data field carries the
machine-readable payload.
Callers control which sections appear through the three boolean flags, making it easy to request a lightweight analysis-only snapshot or a full diagnostic document.
| PARAMETER | DESCRIPTION |
|---|---|
target_path
|
Path to a single file or a directory. When a directory is given, all eligible files inside are analysed.
TYPE:
|
language
|
Explicit language override. When omitted, the language is inferred from file extensions. Default to None.
TYPE:
|
perspective
|
Requested report perspective.
Default to
TYPE:
|
project_as
|
Projection-family target when
TYPE:
|
include_prompts
|
Append remediation prompt sections derived
from
TYPE:
|
include_analysis
|
Include the violation-analysis body showing per-rule findings. Default to True.
TYPE:
|
include_gaps
|
Include quality-gap and coverage-gap summaries highlighting areas that need attention. Default to True.
TYPE:
|
ctx
|
Optional FastMCP context used to emit progress and log updates for analyzed targets. Default to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReportOutput
|
ReportOutput with
TYPE:
|
ReportOutput
|
(structured dict) ready for MCP client consumption. |
See Also
analyze_zen_violations:
Underlying snippet analysis powering the report body.
generate_prompts_tool:
Standalone prompt generation when a full report is not needed.
Source code in src/mcp_zen_of_languages/server.py
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | |
export_rule_detector_mapping
async
¶
Export the live rule-to-detector wiring from the detector registry.
The registry maps each zen rule (e.g. PY-R001) to the detector
class responsible for finding its violations. Exporting this mapping
is useful for introspection dashboards, CI tooling that needs to know
which rules are actively enforced, and documentation generators that
want to list coverage per language.
| PARAMETER | DESCRIPTION |
|---|---|
languages
|
Restrict the export to these language identifiers. When omitted, mappings for every registered language are returned. Default to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Nested dictionary keyed by language, then by rule ID, with
TYPE:
|
dict
|
detector metadata (class name, config schema) as values. |
See Also
get_supported_languages:
Returns the same language keys but paired with detector IDs
rather than full mapping metadata.
Source code in src/mcp_zen_of_languages/server.py
get_config
async
¶
Return a snapshot of the running server's configuration.
Combines the static values loaded from zen-config.yaml with any
session-scoped overrides applied via set_config_override. Useful
for MCP clients that need to display current thresholds or verify
that an override took effect before launching an analysis run.
| RETURNS | DESCRIPTION |
|---|---|
ConfigStatus
|
ConfigStatus describing active languages, severity threshold,
TYPE:
|
ConfigStatus
|
resolved config file path, and a per-language map of overrides. |
See Also
set_config_override:
Mutates the runtime overrides reflected in this snapshot.
clear_config_overrides:
Resets all overrides so the snapshot matches zen-config.yaml.
Source code in src/mcp_zen_of_languages/server.py
set_config_override
async
¶
set_config_override(
language,
max_cyclomatic_complexity=None,
max_nesting_depth=None,
max_function_length=None,
max_class_length=None,
max_line_length=None,
severity_threshold=None,
)
Apply session-scoped threshold overrides for a specific language.
Overrides are stored in memory and survive until the server process
exits or clear_config_overrides is called. Only the fields
explicitly set are overridden — omitted fields retain their
zen-config.yaml defaults. Calling this tool a second time for
the same language replaces the previous override entirely.
| PARAMETER | DESCRIPTION |
|---|---|
language
|
Language whose thresholds should be adjusted
(e.g.
TYPE:
|
max_cyclomatic_complexity
|
Override the per-function cyclomatic-complexity ceiling. Default to None.
TYPE:
|
max_nesting_depth
|
Override the maximum allowed nesting depth for control-flow blocks. Default to None.
TYPE:
|
max_function_length
|
Override the maximum lines Default to None. permitted in a single function body.
TYPE:
|
max_class_length
|
Override the maximum lines permitted in a single class definition. Default to None.
TYPE:
|
max_line_length
|
Override the maximum character width for a single source line. Default to None.
TYPE:
|
severity_threshold
|
Override the minimum severity at which violations are surfaced in results. Default to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ConfigStatus
|
ConfigStatus reflecting all overrides after this mutation,
TYPE:
|
ConfigStatus
|
confirming the change took effect. |
See Also
get_config:
Inspect the full configuration without mutating it.
Source code in src/mcp_zen_of_languages/server.py
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 | |
clear_config_overrides
async
¶
Remove every session-scoped override, reverting to zen-config.yaml defaults.
After this call, get_config().overrides_applied will be empty
and all subsequent analyses will use the thresholds defined in the
static configuration file.
| RETURNS | DESCRIPTION |
|---|---|
ConfigStatus
|
ConfigStatus after all override entries have been cleared.
TYPE:
|
Source code in src/mcp_zen_of_languages/server.py
onboard_project
async
¶
onboard_project(
project_path,
primary_language="python",
team_size="small",
strictness="moderate",
ctx=None,
)
Generate a step-by-step onboarding guide tailored to a project's profile.
The guide walks a new user through five stages — configuration file creation, IDE integration, baseline analysis, threshold tuning, and CI/CD wiring — with concrete examples customised for the selected primary_language and strictness level.
Three strictness presets are available:
- relaxed — generous thresholds suited to legacy codebases.
- moderate — balanced defaults for active development.
- strict — tight limits for greenfield or high-quality projects.
| PARAMETER | DESCRIPTION |
|---|---|
project_path
|
Absolute path to the project root, used to derive the project name and populate example commands.
TYPE:
|
primary_language
|
Language used for example snippets and
default pipeline selection (e.g.
TYPE:
|
team_size
|
Descriptive team-size hint (
TYPE:
|
strictness
|
Preset name controlling all numeric thresholds
(
TYPE:
|
ctx
|
Optional FastMCP context used for elicitation when strictness or language values are ambiguous. Default to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OnboardingGuide
|
OnboardingGuide with ordered steps, each carrying an action key
TYPE:
|
OnboardingGuide
|
and example, plus a |
OnboardingGuide
|
into |
Example
See Also
set_config_override:
Apply recommended thresholds at runtime without editing
zen-config.yaml.
Source code in src/mcp_zen_of_languages/server.py
1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 | |
get_supported_languages
async
¶
List every language that has zen rules alongside its registered detector IDs.
This tool queries two registries at once: ZEN_REGISTRY (which
holds the canonical zen principles per language) and the detector
REGISTRY (which maps rule IDs to detector implementations).
The result tells callers not just which languages are known, but
how much detector coverage each language currently has.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[str]]
|
dict[str, list[str]]: Dictionary mapping each language identifier (e.g. |
dict[str, list[str]]
|
to the list of detector IDs wired up for that language. |
See Also
detect_languages:
Returns the configured language list from zen-config.yaml
rather than the full set of languages with rules.
export_rule_detector_mapping:
Provides deeper mapping metadata including config schemas.
Source code in src/mcp_zen_of_languages/server.py
Tool models¶
mcp_zen_of_languages.models.AnalysisResult
¶
Bases: BaseModel
Primary output produced by every language analyser.
A call to BaseAnalyzer.analyze() returns exactly one
AnalysisResult. It bundles the computed metrics, the full
violation list, and a composite health score into a single,
JSON-serialisable envelope. The MCP server forwards this model
directly to the client; the CLI formats it for terminal display.
Like Violation, this model supports bracket access
(result["violations"]) so that legacy dict-oriented test
assertions continue to pass without rewrites.
| ATTRIBUTE | DESCRIPTION |
|---|---|
language |
Language key used for analysis (e.g.
TYPE:
|
path |
File path, or
TYPE:
|
metrics |
Computed complexity, maintainability, and LOC.
TYPE:
|
violations |
Ordered list of detected zen-principle violations.
TYPE:
|
overall_score |
Composite quality score from 0.0 (worst) to 10.0.
TYPE:
|
rules_summary |
Optional severity histogram for quick triage.
TYPE:
|
Example
result = AnalysisResult( ... language="python", ... path="app/routes.py", ... metrics=Metrics( ... cyclomatic=CyclomaticSummary(blocks=[], average=0.0), ... maintainability_index=80.0, ... lines_of_code=150, ... ), ... violations=[], ... overall_score=9.2, ... ) result["overall_score"] 9.2
See Also
Metrics: The numeric measurements embedded in this result.
Violation: Individual issues inside the violations list.
RepositoryAnalysis: Wraps an AnalysisResult with file metadata.
mcp_zen_of_languages.models.LanguagesResult
¶
Bases: BaseModel
Enumeration of every language the server can currently analyse.
The list_zen_languages MCP tool returns a LanguagesResult so
clients can discover which language keys are valid before calling
analysis endpoints. The list is populated at startup from the
AnalyzerFactory registry and stays stable for the lifetime of the
server process.
| ATTRIBUTE | DESCRIPTION |
|---|---|
languages |
Sorted list of supported language identifiers.
TYPE:
|
Example
lr = LanguagesResult(languages=["python", "rust", "typescript"]) "python" in lr.languages True
See Also
AnalyzerFactory: The registry that defines available languages.
mcp_zen_of_languages.models.PatternsResult
¶
Bases: BaseModel
Bundled response from the architectural-pattern detection pass.
The analyze_zen_patterns MCP tool returns a PatternsResult
containing every pattern that was matched in the target code. An
empty patterns list simply means no known patterns were detected —
it is not an error condition.
| ATTRIBUTE | DESCRIPTION |
|---|---|
patterns |
Ordered list of detected pattern findings.
TYPE:
|
Example
pr = PatternsResult( ... patterns=[ ... PatternFinding(name="observer", details="event bus in signals.py"), ... ] ... ) len(pr.patterns) 1
See Also
PatternFinding: Individual match carried inside the list.
mcp_zen_of_languages.models.RepositoryAnalysis
¶
Bases: BaseModel
Per-file wrapper used when scanning an entire repository.
During a repository-wide analysis the server produces one
RepositoryAnalysis per source file, pairing the file's path and
detected language with the full AnalysisResult. Collecting these
into a list gives the MCP client an iterable, JSON-friendly manifest
of every file that was inspected.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
Repository-relative path to the analysed file.
TYPE:
|
language |
Language key that the analyser factory resolved.
TYPE:
|
result |
Complete analysis output for this file.
TYPE:
|
Example
entry = RepositoryAnalysis( ... path="lib/parser.py", ... language="python", ... result=analysis_result, ... ) entry.path 'lib/parser.py'
See Also
AnalysisResult: The per-file detail carried inside result.
ProjectSummary: Aggregate statistics derived from all entries.
mcp_zen_of_languages.reporting.models.ReportOutput
¶
Bases: BaseModel
Final output of the reporting pipeline.
Carries both a human-readable Markdown report and the equivalent machine- readable data dict so that consumers (CLI, MCP tools, CI integrations) can choose whichever representation fits their needs.
| ATTRIBUTE | DESCRIPTION |
|---|---|
markdown |
Fully rendered Markdown report text (normalised whitespace).
TYPE:
|
data |
Serialised dict mirroring the report structure for JSON output.
TYPE:
|
mcp_zen_of_languages.server.ConfigOverride
¶
Bases: BaseModel
Session-scoped override for a single language's analysis thresholds.
When an MCP client calls set_config_override, the supplied values
are captured in a ConfigOverride instance and stored in the
module-level _runtime_overrides dict, keyed by language. Only
non-None fields are considered active — omitted fields leave the
corresponding zen-config.yaml default in effect.
Note
Overrides do not persist across server restarts. Call
clear_config_overrides to reset mid-session.
mcp_zen_of_languages.server.ConfigStatus
¶
Bases: BaseModel
Read-only snapshot of the server's current configuration state.
Returned by get_config, set_config_override, and
clear_config_overrides so callers can confirm the effective
settings after every mutation. The overrides_applied field
shows only the non-default values injected during the current session.
mcp_zen_of_languages.server.OnboardingStep
¶
Bases: BaseModel
A single instruction in the guided onboarding sequence.
Each step pairs a human-readable title and description with an
action key that MCP clients can use to trigger the corresponding
operation programmatically, and an optional example showing
concrete invocation syntax.
mcp_zen_of_languages.server.OnboardingGuide
¶
Bases: BaseModel
Complete onboarding payload returned by onboard_project.
Bundles an ordered list of OnboardingStep entries with a
recommended_config dict that reflects the thresholds appropriate
for the caller's chosen strictness profile. MCP clients can render
the steps as an interactive wizard or apply recommended_config
directly to zen-config.yaml.