MCP Tools, Resources, and Prompts Reference

View Source

Ragex exposes 72 MCP tools, 6 resources, and 6 prompts via the Model Context Protocol over stdio and Unix socket (/tmp/ragex_mcp.sock).

All tools are called via tools/call with JSON-RPC 2.0. Resources are read via resources/read. Prompts are retrieved via prompts/get.

Quick Reference

{"jsonrpc":"2.0","method":"tools/call","params":{"name":"TOOL_NAME","arguments":{...}},"id":1}

Tools

Indexing and Analysis

analyze_file

Analyze a source file and extract code structure (modules, functions, calls) into the knowledge graph. Supports auto-detection of language from file extension.

ParameterTypeRequiredDefaultDescription
pathstringyesAbsolute or relative path to the file
languagestringnoautoelixir, erlang, python, javascript, typescript, auto
generate_embeddingsbooleannotrueGenerate embeddings for semantic search

analyze_directory

Recursively analyze all supported files in a directory, extracting code structure into the knowledge graph.

ParameterTypeRequiredDefaultDescription
pathstringyesPath to the directory (or file) to analyze
max_depthintegerno10Maximum directory depth to traverse
exclude_patternsstring[]noPatterns to exclude (e.g., node_modules, .git)

watch_directory

Start watching a directory for file changes and auto-reindex modified files.

ParameterTypeRequiredDefaultDescription
pathstringyesDirectory path to watch

unwatch_directory

Stop watching a directory.

ParameterTypeRequiredDefaultDescription
pathstringyesDirectory path to stop watching

list_watched

List all currently watched directories. No parameters.


Knowledge Graph Queries

query_graph

Query the knowledge graph for code entities and relationships.

ParameterTypeRequiredDescription
query_typestringyesfind_module, find_function, get_calls, get_dependencies
paramsobjectyesQuery-specific parameters

list_nodes

List all nodes in the knowledge graph with optional filtering.

ParameterTypeRequiredDefaultDescription
node_typestringnoFilter by node type (module, function, etc.)
limitintegerno100Maximum results

graph_stats

Get comprehensive graph statistics including PageRank and centrality metrics. No parameters.

Returns: node_count, edge_count, average_degree, density, top_by_pagerank, top_by_degree, node_counts_by_type.

find_callers

Find all functions that call a specific function.

ParameterTypeRequiredDescription
modulestringyesModule name (e.g., MyModule)
function_namestringyesFunction name (e.g., process)
arityintegernoFunction arity (searches any arity if omitted)

find_paths

Find all paths (call chains) between two functions or modules.

ParameterTypeRequiredDefaultDescription
fromstringyesSource node ID (e.g., ModuleA.function/1)
tostringyesTarget node ID (e.g., ModuleB.function/2)
max_depthintegerno10Maximum path length

semantic_search

Search codebase using natural language queries via embedding-based semantic similarity.

ParameterTypeRequiredDefaultDescription
querystringyesNatural language query (e.g., "function to parse JSON")
limitintegerno10Maximum results
thresholdnumberno0.2Minimum similarity score (0.0-1.0, typical: 0.1-0.3)
node_typestringnoFilter: module or function
include_contextbooleannotrueInclude related entities (callers, callees)

hybrid_search

Advanced search combining symbolic graph queries with semantic similarity using Reciprocal Rank Fusion.

ParameterTypeRequiredDefaultDescription
querystringyesNatural language search query
strategystringnofusionfusion, semantic_first, graph_first
limitintegerno10Maximum results
thresholdnumberno0.15Minimum similarity score
node_typestringnoFilter: module or function
include_contextbooleannotrueInclude related entities

metaast_search

Search for semantically equivalent code constructs across languages using MetaAST analysis.

ParameterTypeRequiredDefaultDescription
source_languagestringyeselixir, erlang, python, javascript
source_constructstringyese.g., Enum.map/2, list_comprehension, or MetaAST pattern
target_languagesstring[]no[]Target languages (empty = all)
limitintegerno5Max results per language
thresholdnumberno0.6Semantic similarity threshold
strict_equivalencebooleannofalseRequire exact AST match

cross_language_alternatives

Suggest cross-language alternatives for a code construct.

ParameterTypeRequiredDefaultDescription
languagestringyesSource language
codestringyesCode snippet or construct description
target_languagesstring[]no[]Languages to generate alternatives for

expand_query

Expand a search query with semantic synonyms and cross-language terms.

ParameterTypeRequiredDefaultDescription
querystringyesOriginal search query
intentstringnoautoexplain, refactor, example, debug, general
max_termsintegerno5Maximum expansion terms
include_synonymsbooleannotrueInclude semantic synonyms
include_cross_languagebooleannotrueInclude cross-language terms

find_metaast_pattern

Find all implementations of a MetaAST pattern across all languages.

ParameterTypeRequiredDefaultDescription
patternstringyesMetaAST pattern (e.g., collection_op:map, loop:for, lambda)
languagesstring[]no[]Filter by languages (empty = all)
limitintegerno20Maximum results

Graph Algorithms

betweenness_centrality

Compute betweenness centrality to identify bridge/bottleneck functions using Brandes' algorithm.

ParameterTypeRequiredDefaultDescription
max_nodesintegerno1000Limit computation to N highest-degree nodes
normalizebooleannotrueReturn normalized scores (0-1)

closeness_centrality

Compute closeness centrality to identify central functions in the call graph.

ParameterTypeRequiredDefaultDescription
normalizebooleannotrueReturn normalized scores (0-1)

detect_communities

Detect communities/clusters in the call graph to identify architectural modules.

ParameterTypeRequiredDefaultDescription
algorithmstringnolouvainlouvain or label_propagation
max_iterationsintegerno10Maximum iterations
resolutionnumberno1.0Resolution parameter (Louvain only)
hierarchicalbooleannofalseReturn hierarchical structure (Louvain only)
seedintegernoRandom seed (label propagation only)

export_graph

Export the call graph in visualization formats.

ParameterTypeRequiredDefaultDescription
formatstringyesgraphvizgraphviz (DOT) or d3 (JSON)
include_communitiesbooleannotrueInclude community clustering
color_bystringnopagerankpagerank, betweenness, degree (graphviz only)
max_nodesintegerno500Maximum nodes to include

File Editing

edit_file

Safely edit a single file with automatic backup, syntax validation, and atomic operations.

ParameterTypeRequiredDefaultDescription
pathstringyesPath to the file
changesarrayyesList of changes (see below)
validatebooleannotrueValidate syntax before applying
create_backupbooleannotrueCreate backup before editing
languagestringnoautoExplicit language for validation

Each change object:

  • type: replace, insert, or delete
  • line_start: Starting line number (1-indexed)
  • line_end: Ending line (for replace/delete)
  • content: New content (for replace/insert)

edit_files

Atomically edit multiple files with automatic rollback on failure.

ParameterTypeRequiredDefaultDescription
filesarrayyesList of {path, changes, validate?, format?, language} objects
validatebooleannotrueValidate all files before applying
create_backupbooleannotrueCreate backups
formatbooleannofalseFormat code after editing

validate_edit

Preview validation of changes without applying them.

ParameterTypeRequiredDescription
pathstringyesPath to the file
changesarrayyesList of changes to validate
languagestringnoExplicit language for validation

rollback_edit

Undo a recent edit by restoring from backup.

ParameterTypeRequiredDescription
pathstringyesPath to the file
backup_idstringnoSpecific backup to restore (default: most recent)

edit_history

Query backup history for a file.

ParameterTypeRequiredDefaultDescription
pathstringyesPath to the file
limitintegerno10Maximum backups to return

read_file

Read the contents of a source file with line numbers.

ParameterTypeRequiredDescription
pathstringyesAbsolute path to the file
start_lineintegernoStart line (1-indexed)
end_lineintegernoEnd line (1-indexed)

Refactoring

refactor_code

Semantic refactoring operations using AST analysis and knowledge graph.

ParameterTypeRequiredDefaultDescription
operationstringyesrename_function or rename_module
paramsobjectyes{module, old_name, new_name, arity}
scopestringnoprojectmodule or project
validatebooleannotrueValidate before and after
formatbooleannotrueFormat code after refactoring

advanced_refactor

Advanced refactoring operations with 8 operation types.

ParameterTypeRequiredDefaultDescription
operationstringyesSee operations below
paramsobjectyesOperation-specific parameters
validatebooleannotrueValidate before and after
formatbooleannotrueFormat code after refactoring
scopestringnoprojectmodule or project

Operations:

  • extract_function -- params: {module, source_function, source_arity, new_function, line_start, line_end}
  • inline_function -- params: {module, function, arity}
  • convert_visibility -- params: {module, function, arity, visibility} (visibility: public or private)
  • rename_parameter -- params: {module, function, arity, old_name, new_name}
  • modify_attributes -- params: {module, changes} (changes: list of {action, attribute, value})
  • change_signature -- params: {module, function, arity, changes} (changes: list of {action, param_name, position, default})
  • move_function -- params: {source_module, target_module, function, arity}
  • extract_module -- params: {source_module, new_module, functions} (functions: list of {name, arity})

preview_refactor

Preview refactoring changes without applying them. Shows diffs, conflicts, and statistics with optional AI commentary.

ParameterTypeRequiredDefaultDescription
operationstringyesrename_function, rename_module, extract_function, inline_function
paramsobjectyesOperation-specific parameters
formatstringnounifiedunified, side_by_side, json
ai_commentarybooleannotrueGenerate AI risk assessment

refactor_conflicts

Check for conflicts before applying a refactoring operation.

ParameterTypeRequiredDescription
operationstringyesrename_function, rename_module, move_function, extract_module
paramsobjectyesOperation-specific parameters

undo_refactor

Undo the most recent refactoring operation.

ParameterTypeRequiredDescription
project_pathstringnoProject root path (uses cwd if not specified)

refactor_history

List refactoring operation history with timestamps and file counts.

ParameterTypeRequiredDefaultDescription
project_pathstringnocwdProject root path
limitintegerno50Maximum entries
include_undonebooleannofalseInclude undone operations

visualize_impact

Visualize the impact of refactoring changes.

ParameterTypeRequiredDefaultDescription
filesstring[]yesFile paths affected by refactoring
formatstringnoasciigraphviz, d3_json, ascii
depthintegerno1Impact radius depth
include_riskbooleannotrueInclude risk analysis

suggest_refactorings

Analyze code and generate prioritized refactoring suggestions.

ParameterTypeRequiredDefaultDescription
targetstringyesFile path, directory, or module name
patternsstring[]noallFilter: extract_function, inline_function, split_module, merge_modules, remove_dead_code, reduce_coupling, simplify_complexity, extract_module
min_prioritystringnolowinfo, low, medium, high, critical
include_actionsbooleannotrueInclude step-by-step action plans
use_ragbooleannofalseUse RAG for AI-powered advice
formatstringnosummarysummary, detailed, json

explain_suggestion

Get detailed explanation for a specific refactoring suggestion.

ParameterTypeRequiredDefaultDescription
suggestion_idstringyesID from suggest_refactorings response
include_code_contextbooleannotrueInclude relevant code snippets
use_ragbooleannofalseGenerate enhanced explanation using RAG

estimate_refactoring_effort

Estimate effort required for a refactoring operation.

ParameterTypeRequiredDefaultDescription
operationstringyesrename_function, rename_module, extract_function, inline_function, move_function, change_signature
targetstringyesModule.function/arity or Module
formatstringnosummarysummary, detailed, json

risk_assessment

Calculate risk score for changing a function or module.

ParameterTypeRequiredDefaultDescription
targetstringyesModule.function/arity or Module
formatstringnosummarysummary, detailed, json

Code Quality and Analysis

analyze_quality

Analyze code quality metrics (complexity, purity, LOC) using Metastatic.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
metricsstring[]noallcyclomatic, cognitive, nesting, halstead, loc, function_metrics, purity
store_resultsbooleannotrueStore in knowledge graph
recursivebooleannotrueRecurse directories

quality_report

Generate a comprehensive quality report for analyzed files.

ParameterTypeRequiredDefaultDescription
report_typestringnosummarysummary, detailed, by_language, trends
formatstringnotexttext, json, markdown
include_filesbooleannofalseInclude individual file details

find_complex_code

Find files or functions exceeding complexity thresholds.

ParameterTypeRequiredDefaultDescription
metricstringnocyclomaticcyclomatic, cognitive, nesting
thresholdnumberno10Threshold value
comparisonstringnogtgt, gte, lt, lte, eq
limitintegerno20Maximum results
sort_orderstringnodescasc or desc
show_functionsbooleannofalseInclude per-function breakdown

detect_smells

Detect code smells: long functions, deep nesting, magic numbers, complex conditionals, long parameter lists.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
recursivebooleannotrueRecurse directories
min_severitystringnolowlow, medium, high, critical
thresholdsobjectno{max_statements: 50, max_nesting: 4, max_parameters: 5, max_cognitive: 15}
smell_typesstring[]noalllong_function, deep_nesting, magic_number, complex_conditional, long_parameter_list

analyze_business_logic

Analyze files for business logic issues using 33 analyzers (20 business logic + 13 CWE-based security).

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
analyzersstring[]noallFilter specific analyzers (see below)
min_severitystringnoinfoinfo, low, medium, high, critical
recursivebooleannotrueRecurse directories
formatstringnosummarysummary, detailed, json

Business logic analyzers: callback_hell, missing_error_handling, silent_error_case, swallowing_exception, hardcoded_value, n_plus_one_query, inefficient_filter, unmanaged_task, telemetry_in_recursive_function, missing_telemetry_for_external_http, sync_over_async, direct_struct_update, missing_handle_async, blocking_in_plug, missing_telemetry_in_auth_plug, missing_telemetry_in_liveview_mount, missing_telemetry_in_oban_worker, missing_preload, inline_javascript, missing_throttle.

CWE-based security analyzers: sql_injection (CWE-89), xss_vulnerability (CWE-79), ssrf_vulnerability (CWE-918), path_traversal (CWE-22), insecure_direct_object_reference (CWE-639), missing_authentication (CWE-306), missing_authorization (CWE-862), incorrect_authorization (CWE-863), missing_csrf_protection (CWE-352), sensitive_data_exposure (CWE-200), unrestricted_file_upload (CWE-434), improper_input_validation (CWE-20), toctou (CWE-367).


Dependency and Dead Code Analysis

analyze_dependencies

Analyze module dependencies -- coupling metrics, circular dependencies, relationships.

ParameterTypeRequiredDefaultDescription
modulestringnoallModule name to analyze
include_transitivebooleannofalseInclude transitive dependencies
formatstringnosummarysummary, detailed, json

find_circular_dependencies

Find circular dependencies in the codebase.

ParameterTypeRequiredDefaultDescription
scopestringnomodulemodule or function
min_cycle_lengthintegerno2Minimum cycle length
limitintegerno100Maximum cycles to return

coupling_report

Generate coupling metrics report with afferent/efferent coupling and instability.

ParameterTypeRequiredDefaultDescription
formatstringnotexttext, json, markdown
sort_bystringnoinstabilityname, instability, afferent, efferent
include_transitivebooleannofalseInclude transitive metrics
thresholdintegerno0Minimum total coupling (0 = show all)

find_dead_code

Find potentially unused code (functions with no callers) with confidence scoring.

ParameterTypeRequiredDefaultDescription
scopestringnoallexports, private, all, modules
min_confidencenumberno0.5Confidence threshold (0.0-1.0)
exclude_testsbooleannotrueExclude test modules
include_callbacksbooleannofalseInclude potential callbacks
formatstringnosummarysummary, detailed, suggestions

analyze_dead_code_patterns

Analyze files for intraprocedural dead code patterns (unreachable code, constant conditionals) using AST analysis.

ParameterTypeRequiredDefaultDescription
pathstringyesFile path or directory
min_confidencestringnolowlow, medium, high
formatstringnosummarysummary, detailed, json

analyze_impact

Analyze the impact of changing a function or module via graph traversal.

ParameterTypeRequiredDefaultDescription
targetstringyesModule.function/arity or Module
depthintegerno5Maximum traversal depth
include_testsbooleannotrueInclude test files
formatstringnosummarysummary, detailed, json

Duplicate Detection

find_duplicates

Find code duplicates using AST-based clone detection (Type I-IV) via Metastatic. Works across languages.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory (comma-separated for comparison)
thresholdnumberno0.8Similarity threshold for Type III clones
recursivebooleannotrueRecurse directories
formatstringnosummarysummary, detailed, json
exclude_patternsstring[]no[_build, deps, .git]Exclusion patterns

find_similar_code

Find semantically similar code using embedding-based similarity.

ParameterTypeRequiredDefaultDescription
thresholdnumberno0.95Similarity threshold
limitintegerno100Maximum pairs to return
node_typestringnofunctionfunction or module
formatstringnosummarysummary, detailed, json

Security

scan_security

Scan for security vulnerabilities: injection, unsafe deserialization, hardcoded secrets, weak crypto.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
recursivebooleannotrueRecurse directories
min_severitystringnolowlow, medium, high, critical
categoriesstring[]noallinjection, unsafe_deserialization, hardcoded_secret, weak_cryptography, insecure_protocol

security_audit

Generate comprehensive security audit report with CWE mapping and recommendations.

ParameterTypeRequiredDefaultDescription
pathstringyesDirectory path to audit
formatstringnotextjson, markdown, text
min_severitystringnolowlow, medium, high, critical

check_secrets

Scan for hardcoded secrets (API keys, passwords, tokens) in source code.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
recursivebooleannotrueRecurse directories

analyze_security_issues

Run all 13 CWE-based security analyzers: SQL injection, XSS, SSRF, path traversal, authentication/authorization issues, CSRF, data exposure, etc.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
min_severitystringnolowinfo, low, medium, high, critical
recursivebooleannotrueRecurse directories
categoriesstring[]noallinjection, authentication, authorization, data_exposure, input_validation, race_condition
formatstringnosummarysummary, detailed, json

Semantic Analysis

semantic_operations

Extract semantic operations (OpKind) from code -- identifies database, auth, HTTP, cache, queue, file, and external API operations with framework-specific patterns.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
domainsstring[]noalldb, http, auth, cache, queue, file, external_api
recursivebooleannotrueRecurse directories
include_securitybooleannotrueInclude security-relevant operations
formatstringnosummarysummary, detailed, json

semantic_analysis

Full semantic analysis combining OpKind extraction with security assessment.

ParameterTypeRequiredDefaultDescription
pathstringyesFile or directory path
recursivebooleannotrueRecurse directories
include_operationsbooleannotrueInclude operation breakdown by domain
include_securitybooleannotrueInclude security analysis
formatstringnosummarysummary, detailed, json

RAG (Retrieval-Augmented Generation)

All RAG tools require an AI provider to be configured (DeepSeek, OpenAI, Anthropic, or Ollama).

rag_query

Query codebase using RAG with AI.

ParameterTypeRequiredDefaultDescription
querystringyesNatural language query about the codebase
limitintegerno10Max code snippets to retrieve
include_codebooleannotrueInclude full code snippets
providerstringnodefaultdeepseek_r1, openai, anthropic, ollama

rag_explain

Explain code using RAG with AI assistance.

ParameterTypeRequiredDefaultDescription
targetstringyesFile path or Module.function/2
aspectstringnoallpurpose, complexity, dependencies, all

rag_suggest

Suggest code improvements using RAG with AI.

ParameterTypeRequiredDefaultDescription
targetstringyesFile path or function identifier
focusstringnoallperformance, readability, testing, security, all

rag_query_stream

Same as rag_query but uses streaming internally. Returns complete result.

Additional parameter: show_chunks (boolean, default: false) -- include intermediate chunks for debugging.

rag_explain_stream

Same as rag_explain with internal streaming. Additional: show_chunks.

rag_suggest_stream

Same as rag_suggest with internal streaming. Additional: show_chunks.

validate_with_ai

Validate code with AI-enhanced error explanations and fix suggestions.

ParameterTypeRequiredDefaultDescription
contentstringyesCode content to validate
pathstringnoFile path (for language detection)
languagestringnoautoelixir, erlang, python, javascript, typescript
ai_explainbooleannotrueEnable AI explanations
surrounding_linesintegerno3Context lines around errors

AI and Embeddings

get_embeddings_stats

Get statistics about indexed embeddings. No parameters.

get_ai_usage

Get AI provider usage statistics (requests, tokens, costs).

ParameterTypeRequiredDescription
providerstringnoFilter by openai, anthropic, deepseek_r1, ollama

get_ai_cache_stats

Get AI response cache statistics and hit rates. No parameters.

clear_ai_cache

Clear AI response cache.

ParameterTypeRequiredDescription
operationstringnoquery, explain, suggest, or all

Agent

The agent system provides conversational analysis sessions with persistent context.

agent_analyze

Analyze a project and generate an AI-polished report. Creates a session for follow-up conversation.

ParameterTypeRequiredDefaultDescription
pathstringyesProject root path
providerstringnodeepseek_r1AI provider
include_suggestionsbooleannotrueInclude refactoring suggestions
skip_embeddingsbooleannofalseSkip embeddings for faster analysis

Returns a session_id for use with agent_chat.

agent_chat

Continue conversation with the agent in an existing session.

ParameterTypeRequiredDescription
session_idstringyesSession ID from agent_analyze
messagestringyesUser message or question
providerstringnoAI provider override

agent_session_info

Get information about an agent session.

ParameterTypeRequiredDescription
session_idstringyesSession ID

agent_list_sessions

List all active agent sessions.

ParameterTypeRequiredDefaultDescription
limitintegerno20Maximum sessions

agent_clear_session

End and clear an agent session.

ParameterTypeRequiredDescription
session_idstringyesSession ID

Resources

Resources provide read-only access to Ragex's internal state. Read via resources/read with the resource URI.

{"jsonrpc":"2.0","method":"resources/read","params":{"uri":"ragex://graph/stats"},"id":1}

ragex://graph/stats -- Graph Statistics

Comprehensive knowledge graph statistics including node/edge counts, PageRank scores, and centrality metrics.

Returns: node_count, node_counts_by_type, edge_count, average_degree, density, top_by_pagerank, top_by_degree.

ragex://cache/status -- Cache Status

Embedding cache statistics including hit rates, file tracking status, and disk usage.

Returns: cache_enabled, cache_file, cache_size_bytes, cache_valid, embeddings_count, model_name, last_saved, tracked_files, changed_files, unchanged_files, stale_entities_count.

ragex://model/config -- Model Configuration

Active embedding model configuration including name, dimensions, capabilities, and readiness.

Returns: model_name, dimensions, ready, memory_usage_mb, capabilities (supports_batch, supports_normalization, local_inference), parameters (max_sequence_length, pooling).

ragex://project/index -- Project Index

Index of all tracked files with metadata, language distribution, and LOC statistics.

Returns: total_files, tracked_files (first 100 with path, content_hash, analyzed_at, size_bytes, language), language_distribution, recently_changed, changed_files_count, total_entities, entities_by_type.

ragex://algorithms/catalog -- Algorithm Catalog

Catalog of available graph algorithms with parameters, complexity, and use cases.

Includes: pagerank, betweenness_centrality, closeness_centrality, degree_centrality, find_paths, detect_communities. Each with parameters, complexity notation, and use case descriptions.

ragex://analysis/summary -- Analysis Summary

Pre-computed analysis summary including key modules, architectural insights, and community structure.

Returns: overview (total_nodes, total_edges, average_degree, density), key_modules (by PageRank), bottlenecks (by betweenness centrality), communities (top 10 by size), community_count.


Prompts

Prompts are templated high-level workflows that compose multiple tools. Retrieved via prompts/get.

{"jsonrpc":"2.0","method":"prompts/get","params":{"name":"analyze_architecture","arguments":{"path":"/path/to/project"}},"id":1}

analyze_architecture

Comprehensive architectural analysis: community detection, centrality metrics, structural insights.

ArgumentRequiredDescription
pathyesPath to analyze
depthnoshallow (quick) or deep (detailed with betweenness centrality and communities)

find_impact

Analyze the impact and importance of a function: callers, importance scores, refactoring risk.

ArgumentRequiredDescription
moduleyesModule name
functionyesFunction name
arityyesFunction arity

explain_code_flow

Explain execution flow between two functions with narrative description and code context.

ArgumentRequiredDescription
from_functionyesStarting function (Module.function/arity)
to_functionyesTarget function (Module.function/arity)
context_linesnoContext lines to show (default: 3)

find_similar_code

Find code similar to a natural language description using hybrid search.

ArgumentRequiredDescription
descriptionyesNatural language description
file_typenoLanguage filter (e.g., elixir, python)
top_knoNumber of results (default: 5)

suggest_refactoring

Analyze code and suggest refactoring opportunities.

ArgumentRequiredDescription
target_pathyesPath to analyze
focusnomodularity, coupling, or complexity

safe_rename

Preview and optionally perform safe semantic renaming with impact analysis.

ArgumentRequiredDescription
typeyesfunction or module
old_nameyesCurrent name
new_nameyesNew name
scopenomodule or project (default: project)

Supported Languages

  • Elixir (.ex, .exs) -- full support including AST-aware refactoring
  • Erlang (.erl, .hrl) -- analysis, search, quality metrics
  • Python (.py) -- analysis, search, quality metrics
  • JavaScript (.js, .jsx, .mjs) -- analysis, search, quality metrics
  • TypeScript (.ts, .tsx) -- analysis, search, quality metrics

Connection

stdio: Launch with mix run --no-halt. Send JSON-RPC 2.0 messages to stdin, read responses from stdout. Used by MCP-compatible clients (Claude Desktop, etc.).

Unix socket: Connect to /tmp/ragex_mcp.sock. Each request is a single JSON-RPC 2.0 line terminated by \n. Used by editor integrations (NeoVim, LunarVim).

# Example: ping the socket server
(echo '{"jsonrpc":"2.0","method":"ping","id":1}'; sleep 3) | socat -T5 STDIO UNIX-CONNECT:/tmp/ragex_mcp.sock