Skip to content

V3 Configuration

Matt Meents edited this page Nov 30, 2025 · 1 revision

V3 Configuration Guide

Complete configuration reference for DaemonsMCP Version 3.


Configuration Files

V3 uses daemonsmcp.json for configuration instead of the standard appsettings.json. This allows for environment-specific overrides and clearer separation from ASP.NET defaults. so both are include because ef core uses appsettings.json... live and learn.

File Locations

  • API Project: server/DaemonsMCP.Api/daemonsmcp.json
  • MCP Project: server/DaemonsMCP/daemonsmcp.json
  • Environment Override: daemonsmcp.{Environment}.json

Configuration Priority (Highest to Lowest)

  1. Command line arguments
  2. Environment variables
  3. daemonsmcp.{Environment}.json (e.g., daemonsmcp.Development.json)
  4. daemonsmcp.json

Basic Configuration

Minimal daemonsmcp.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP;Integrated Security=True;TrustServerCertificate=True;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Database Configuration

Connection Strings

The ConnectionStrings:DefaultConnection setting controls database connectivity.

Windows Authentication (Recommended)

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP;Integrated Security=True;TrustServerCertificate=True;"
  }
}

Alternate format:

"DefaultConnection": "Server=localhost;Database=DaemonsMCP;Trusted_Connection=true;TrustServerCertificate=true;"

SQL Server Authentication

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP;User Id=your_username;Password=your_password;TrustServerCertificate=True;"
  }
}

⚠️ Security Warning: Never commit passwords to version control. Use environment variables or user secrets for production.

LocalDB (Lightweight Development)

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=DaemonsMCP;Trusted_Connection=true;"
  }
}

Remote SQL Server

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=192.168.1.100,1433;Database=DaemonsMCP;User Id=daemonsmcp_user;Password=SecurePassword123;TrustServerCertificate=True;"
  }
}

Connection String Components

Parameter Description Example
Server SQL Server instance localhost, .\SQLEXPRESS, 192.168.1.100
Database Database name DaemonsMCP
Integrated Security Use Windows auth True or SSPI
Trusted_Connection Same as Integrated Security true
User Id SQL auth username sa, daemonsmcp_user
Password SQL auth password YourPassword
TrustServerCertificate Accept self-signed certs True
Encrypt Force encryption True (optional)
MultipleActiveResultSets Enable MARS True (optional)

Logging Configuration

Log Levels

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning",
      "Microsoft.EntityFrameworkCore": "Warning",
      "DaemonsMCP": "Debug"
    }
  }
}

Available Log Levels (Most to Least Verbose)

  • Trace - Very detailed, typically only for debugging
  • Debug - Detailed diagnostic information
  • Information - General informational messages
  • Warning - Warnings about potential issues
  • Error - Error messages
  • Critical - Critical failures
  • None - Disable logging

Namespace-Specific Logging

Control logging for specific namespaces:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "DaemonsMCP.Application": "Debug",
      "DaemonsMCP.Infrastructure.Services.FileWatcherService": "Debug",
      "Microsoft.EntityFrameworkCore.Database.Command": "Warning",
      "System.Net.Http.HttpClient": "Warning"
    }
  }
}

Log File Locations

Serilog is configured to write logs to:

Windows:

%LOCALAPPDATA%\DaemonsMCP\Logs\

Log Files:

  • D3MCP-YYYYMMDD.log - All logs (Information and above)
  • D3MCP-errors-YYYYMMDD.log - Errors and warnings only

Retention:

  • General logs: 7 days
  • Error logs: 30 days

CORS Configuration

CORS (Cross-Origin Resource Sharing) is required for the Angular web interface.

Default Configuration (Development)

Already configured in Program.cs:

builder.Services.AddCors(options =>
{
  options.AddPolicy("LocalDev", policy =>
  {
    policy.WithOrigins("http://localhost:4200")
          .AllowAnyHeader()
          .AllowAnyMethod();
  });
});

Production CORS

For production deployments, restrict CORS to specific domains:

builder.Services.AddCors(options =>
{
  options.AddPolicy("Production", policy =>
  {
    policy.WithOrigins(
            "https://yourdomain.com",
            "https://app.yourdomain.com"
          )
          .AllowAnyHeader()
          .AllowAnyMethod()
          .AllowCredentials();
  });
});

app.UseCors("Production");

Or configure via daemonsmcp.json:

{
  "Cors": {
    "AllowedOrigins": [
      "https://yourdomain.com",
      "https://app.yourdomain.com"
    ]
  }
}

Environment-Specific Configuration

Development Environment

Create daemonsmcp.Development.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP_Dev;Integrated Security=True;TrustServerCertificate=True;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "DaemonsMCP": "Trace"
    }
  }
}

Production Environment

Create daemonsmcp.Production.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=prod-sql-server;Database=DaemonsMCP;User Id=daemonsmcp_app;Password=UseEnvironmentVariableInstead;TrustServerCertificate=True;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "DaemonsMCP": "Information"
    }
  },
  "AllowedHosts": "yourdomain.com"
}

Setting Environment

Visual Studio:

  1. Right-click project → Properties
  2. Debug → General → Open debug launch profiles UI
  3. Set ASPNETCORE_ENVIRONMENT to Development or Production

Command Line:

# Windows
set ASPNETCORE_ENVIRONMENT=Production
dotnet run

# Linux/macOS
export ASPNETCORE_ENVIRONMENT=Production
dotnet run

Claude Desktop Config:

{
  "mcpServers": {
    "daemons3mcp": {
      "command": "C:\\YourPath\\DaemonsMCP\\server\\DaemonsMCP\\bin\\Debug\\net9.0-windows7.0\\Daemons3MCP.exe",
      "args": []
    }
  }
}

Sensitive Configuration (User Secrets)

For development, use .NET User Secrets instead of committing sensitive data.

Enable User Secrets

cd server/DaemonsMCP.Api
dotnet user-secrets init

Set Secrets

dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=localhost;Database=DaemonsMCP;User Id=sa;Password=MySecretPassword;"

List Secrets

dotnet user-secrets list

User secrets override daemonsmcp.json in Development environment only.


Project Configuration

Projects are configured in the database, not in JSON files.

Creating Projects

Via REST API (Recommended)

Using Swagger UI:

  1. Navigate to https://localhost:44356/swagger
  2. Expand POST /api/projects
  3. Click "Try it out"
  4. Enter project details:
   {
     "name": "MyProject",
     "description": "My C# project",
     "rootPath": "C:\\Code\\MyProject"
   }
  1. Click "Execute"

Using curl:

curl -X POST https://localhost:44356/api/projects \
  -H "Content-Type: application/json" \
  -d '{
    "name": "MyProject",
    "description": "My C# project", 
    "rootPath": "C:\\Code\\MyProject"
  }'

Using Postman:

  • Method: POST
  • URL: https://localhost:44356/api/projects
  • Headers: Content-Type: application/json
  • Body (raw JSON):
  {
    "name": "MyProject",
    "description": "My C# project",
    "rootPath": "C:\\Code\\MyProject"
  }

Via Angular UI (Coming Soon)

The Angular config viewer will provide project management UI.

Via Database (Advanced)

Direct SQL insert:

INSERT INTO Projects (Name, Description, RootPath, CreatedAt)
VALUES ('MyProject', 'My C# project', 'C:\Code\MyProject', GETDATE());

Project Security

Projects enforce strict path security:

  • All file operations are scoped within RootPath
  • Path traversal attacks (../, ..\) are blocked
  • Paths are normalized to forward slashes
  • Only absolute paths within project root are allowed

Performance Tuning

Entity Framework Configuration

Configure EF Core performance in Infrastructure layer:

Connection Pooling (default: enabled):

services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(connectionString, sqlOptions =>
    {
        sqlOptions.EnableRetryOnFailure(
            maxRetryCount: 3,
            maxRetryDelay: TimeSpan.FromSeconds(5),
            errorNumbersToAdd: null
        );
        sqlOptions.CommandTimeout(30); // seconds
    })
);

File Watching Configuration

File watcher behavior is controlled in code, but you can adjust:

Debounce Settings (in FileWatcherService.cs):

  • Debounce delay: 5 seconds (default)
  • Batch processing interval: 5 seconds
  • Process after queue is idle for 5 seconds

Indexing Performance

Batch Size: Controlled in ObjectHierarchyIndexingService

  • Default: Process all queued files per batch
  • Files are indexed using Roslyn asynchronously

For large codebases:

  1. Increase SQL Server memory allocation
  2. Consider indexing hours (off-peak)
  3. Monitor IndexingQueue table size

Security Configuration

API Security (Future Enhancement)

V3 currently runs locally without authentication. For production:

Add Authentication in Program.cs:

builder.Services.AddAuthentication()
    .AddJwtBearer(options => { /* config */ });

app.UseAuthentication();
app.UseAuthorization();

Database Security

Create Dedicated User:

CREATE LOGIN daemonsmcp_app WITH PASSWORD = 'SecurePassword123';
CREATE USER daemonsmcp_app FOR LOGIN daemonsmcp_app;

USE DaemonsMCP;
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO daemonsmcp_app;

Connection String:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP;User Id=daemonsmcp_app;Password=SecurePassword123;TrustServerCertificate=True;"
  }
}

Troubleshooting Configuration

Configuration Not Loading

Symptom: Changes to daemonsmcp.json not reflected

Solutions:

  1. Verify file is in correct directory (DaemonsMCP.Api or DaemonsMCP)
  2. Check Build Action in Visual Studio: should be Content
  3. Check Copy to Output Directory: should be Copy if newer
  4. Restart application
  5. Check for syntax errors (use JSON validator)

Connection String Issues

Symptom: "Cannot open database" or "Login failed"

Solutions:

  1. Verify SQL Server is running
  2. Test connection string with sqlcmd:
   sqlcmd -S localhost -U sa -P YourPassword -Q "SELECT @@VERSION"
  1. Check SQL Server authentication mode (Windows + SQL)
  2. Verify database exists: SELECT name FROM sys.databases
  3. Check firewall if using remote server

Log Files Not Created

Symptom: No log files in %LOCALAPPDATA%\DaemonsMCP\Logs\

Solutions:

  1. Check folder permissions
  2. Verify Serilog configuration in Program.cs
  3. Look for startup errors in console output
  4. Check if CommonPath.LogsAppPath is correct

Best Practices

Development

  • Use Integrated Security=True (Windows auth)
  • Keep verbose logging (Debug level)
  • Use LocalDB for isolated testing
  • Enable detailed EF Core logging

Production

  • Use dedicated SQL user with minimal permissions
  • Store passwords in environment variables or Azure Key Vault
  • Set logging to Warning or Error level
  • Enable connection pooling
  • Use SSL/TLS for database connections (Encrypt=True)
  • Restrict CORS to specific domains
  • Monitor log files and set up alerts

Source Control

  • Commit daemonsmcp.json with safe defaults
  • Never commit daemonsmcp.{Environment}.json with secrets
  • Add to .gitignore:
  daemonsmcp.Development.json
  daemonsmcp.Production.json
  **/appsettings.*.json
  • Use User Secrets for local development
  • Document required configuration in README

Next Steps


Configuration Examples

Multi-Project Setup

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=DaemonsMCP;Integrated Security=True;TrustServerCertificate=True;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  }
}

Then create projects via API:

  • MyWebAppC:\Code\MyWebApp
  • SharedLibraryC:\Code\SharedLibrary
  • MobileAppC:\Code\MobileApp

Team Development

Each developer maintains their own daemonsmcp.Development.json:

Developer 1 (LocalDB):

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=DaemonsMCP_Dev1;Trusted_Connection=true;"
  }
}

Developer 2 (Local SQL Express):

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=DaemonsMCP_Dev2;Integrated Security=True;TrustServerCertificate=True;"
  }
}

Shared SQL Server:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=dev-sql-server;Database=DaemonsMCP_Shared;User Id=dev_user;Password=DevPassword123;TrustServerCertificate=True;"
  }
}

Clone this wiki locally