You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-32700 Error de parsing
-32600 Solicitud inválida
-32601 Método no encontrado
-32602 Parámetros inválidos
-32603 Error interno
-32000 a -32099 Errores definidos por el servidor
2. Herramienta con Esquema de Entrada (Ejercicio 2)
publicclassGetCustomersTool{publicstringName=>"get_customers";publicobjectInputSchema=>new{type="object",properties=new{region=new{type="string",description="Filtrar por región"},limit=new{type="integer",minimum=1,maximum=100}},required=new[]{"region"}};publicasyncTask<object>ExecuteAsync(JsonElementarguments){varregion=arguments.GetProperty("region").GetString();varlimit=arguments.TryGetProperty("limit",outvarl)?l.GetInt32():10;varcustomers=await_repository.GetByRegionAsync(region,limit);returnnew{customers,count=customers.Count};}}
publicclassVirtualAnalyst{privatereadonlySqlMcpClient_sqlClient;privatereadonlyCosmosMcpClient_cosmosClient;privatereadonlyRestMcpClient_restClient;privatereadonlyIMemoryCache_cache;publicasyncTask<string>AnswerAsync(stringnaturalLanguageQuery){// 1. Parsear la intenciónvarintent=ParseQuery(naturalLanguageQuery);// 2. Determinar qué servidores llamarvartasks=newList<Task<object>>();if(intent.NeedsSqlData)tasks.Add(_sqlClient.QueryAsync(intent.SqlQuery));if(intent.NeedsCosmosData)tasks.Add(_cosmosClient.GetSessionAsync(intent.SessionId));if(intent.NeedsExternalApi)tasks.Add(_restClient.CallAsync(intent.ApiEndpoint));// 3. Ejecutar en paralelovarresults=awaitTask.WhenAll(tasks);// 4. Agregar y formatearreturnFormatResponse(results,intent);}}
⚡ Comandos PowerShell
Configuración y Verificación
# Verificar todos los requisitos previos
.\scripts\check-prerequisites.ps1 -Verbose
# Generar datos de ejemplo
.\scripts\create-sample-data.ps1
# Verificar ejercicio específico
.\scripts\verify-exercise1.ps1
.\scripts\verify-exercise2.ps1
.\scripts\verify-exercise3.ps1 -Token "your-jwt-token"
.\scripts\verify-exercise4.ps1
# Ejecutar todas las pruebas
.\scripts\run-all-tests.ps1 -Coverage $true# Iniciar todos los servidores del Ejercicio 4
.\scripts\start-exercise4-servers.ps1
Flujo de Desarrollo
# Crear nuevo proyecto de servidor MCP
dotnet new web -n MyMcpServer
cd MyMcpServer
dotnet add package ModelContextProtocol
dotnet add package Microsoft.EntityFrameworkCore --version 10.0.0# Compilar y ejecutar
dotnet build
dotnet run --urls "http://localhost:5000"# Ejecutar con perfil específico
dotnet run --launch-profile Development
# Modo watch (recompilación automática)
dotnet watch run
# Cambiar puerto$env:ASPNETCORE_URLS="http://localhost:5000"
dotnet run
# Buscar y cerrar proceso
netstat -ano | findstr :5000
taskkill /PID <PID>/F
Problemas con NuGet
# Limpiar caché de NuGet
dotnet nuget locals all --clear
# Restaurar con logging detallado
dotnet restore --verbosity detailed
# Usar fuente específica
dotnet add package ModelContextProtocol --source https://api.nuget.org/v3/index.json --prerelease
Depuración de JWT
// Registrar claims del tokenvarhandler=newJwtSecurityTokenHandler();vartoken=handler.ReadJwtToken(tokenString);Console.WriteLine(string.Join("\n",token.Claims.Select(c =>$"{c.Type}: {c.Value}")));// Decodificar token en línea: https://jwt.io
Serialización JSON
// Deserialización sin distinguir mayúsculas/minúsculasvaroptions=newJsonSerializerOptions{PropertyNameCaseInsensitive=true,WriteIndented=true,DefaultIgnoreCondition=JsonIgnoreCondition.WhenWritingNull};