Configurar una rutina de búsqueda de precodificación de MCP significa configurar su entorno de Claude Code para que el agente busque documentación y referencias de API antes de generar código, evitando importaciones alucinantes y llamadas API obsoletas. Al agregar el servidor Scavio MCP y una instrucción CLAUDE.md, crea un flujo de trabajo donde Claude Code verifica las versiones de los paquetes, lee los registros de cambios y verifica las firmas API con los datos de búsqueda en vivo antes de escribir una sola línea.
Requisitos previos
- Claude Code instalado y configurado
- Clave API de Scavio de scavio.dev
- Un directorio de proyectos con CLAUDE.md
Guia paso a paso
Paso 1: Configurar el servidor Scavio MCP
Agregue el servidor Scavio MCP a su proyecto para que Claude Code pueda llamar a las herramientas de búsqueda.
cat > .mcp.json << 'MCPEOF'
{
"mcpServers": {
"scavio": {
"url": "https://mcp.scavio.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_SCAVIO_API_KEY"
}
}
}
}
MCPEOFPaso 2: Agregue instrucciones de búsqueda precodificadas a CLAUDE.md
Escriba instrucciones en su CLAUDE.md que le indiquen a Claude Code que busque antes de codificar. Esto crea la rutina de búsqueda automática de precodificación.
cat >> CLAUDE.md << 'EOF'
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version: "[library name] latest version 2026"
2. Search for the API signature: "[library name] [function] API reference"
3. If the library was updated in the last 6 months, search for migration guides
4. Verify import paths match the current version
Do NOT rely on training data for:
- Package versions or install commands
- API endpoint URLs or authentication methods
- Configuration file formats
- CLI flag syntax
EOFPaso 3: Agregar reglas de búsqueda específicas del dominio
Amplíe la rutina con reglas específicas del proyecto que se dirigen a los marcos y API que utiliza su equipo.
cat >> CLAUDE.md << 'EOF'
## Project-Specific Search Rules
Always verify before using:
- Next.js: search "next.js [feature] app router" (not pages router)
- Stripe: search "stripe api [endpoint] 2026" (API changes frequently)
- Prisma: search "prisma [method] latest" (ORM syntax varies by version)
- AWS SDK: search "aws sdk v3 [service]" (v2 is deprecated)
EOFPaso 4: Prueba la rutina
Abra Claude Code y asígnele una tarea que requiera conocimientos de API externos. Verifique que busque antes de codificar.
# In Claude Code, try:
# 'Add Stripe checkout to this Next.js app'
#
# Expected behavior:
# 1. Claude searches 'stripe checkout api next.js 2026'
# 2. Claude searches 'next.js server actions stripe'
# 3. Claude writes code using verified API signatures
#
# Without the routine, Claude might use:
# - Deprecated Stripe API methods
# - Pages router patterns instead of App Router
# - Wrong import paths from outdated training dataEjemplo en Python
# Generate the MCP config and CLAUDE.md programmatically
import json, os
def setup_pre_coding_routine(project_dir, api_key, frameworks=None):
# Write MCP config
mcp_config = {
'mcpServers': {
'scavio': {
'url': 'https://mcp.scavio.dev/mcp',
'headers': {'Authorization': f'Bearer {api_key}'}
}
}
}
mcp_path = os.path.join(project_dir, '.mcp.json')
with open(mcp_path, 'w') as f:
json.dump(mcp_config, f, indent=2)
# Append search routine to CLAUDE.md
routine = '''
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version
2. Search for the API signature or reference docs
3. Check for recent breaking changes or migration guides
4. Verify import paths match the current version
'''
if frameworks:
routine += '\n## Framework-Specific Rules\n'
for fw in frameworks:
routine += f'- {fw}: always search "{fw} latest API" before using\n'
claude_md_path = os.path.join(project_dir, 'CLAUDE.md')
with open(claude_md_path, 'a') as f:
f.write(routine)
print(f'MCP config written to {mcp_path}')
print(f'Search routine appended to {claude_md_path}')
setup_pre_coding_routine('.', 'YOUR_API_KEY', ['Next.js', 'Stripe', 'Prisma'])Ejemplo en JavaScript
const fs = require('fs');
function setupPreCodingRoutine(projectDir, apiKey, frameworks = []) {
const mcpConfig = {
mcpServers: {
scavio: {
url: 'https://mcp.scavio.dev/mcp',
headers: {Authorization: \`Bearer \${apiKey}\`}
}
}
};
fs.writeFileSync(\`\${projectDir}/.mcp.json\`, JSON.stringify(mcpConfig, null, 2));
let routine = \`
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version
2. Search for the API signature or reference docs
3. Check for recent breaking changes
4. Verify import paths match the current version
\`;
if (frameworks.length) {
routine += '\n## Framework-Specific Rules\n';
frameworks.forEach(fw => {
routine += \`- \${fw}: always search "\${fw} latest API" before using\n\`;
});
}
fs.appendFileSync(\`\${projectDir}/CLAUDE.md\`, routine);
console.log('MCP config and search routine configured');
}
setupPreCodingRoutine('.', 'YOUR_API_KEY', ['Next.js', 'Stripe', 'Prisma']);Salida esperada
MCP config written to .mcp.json
Search routine appended to CLAUDE.md
Claude Code now searches docs and API references before writing code.