From 1b82ff54a9f983d68d363851289227fe23cd10a7 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 19 Dec 2025 14:51:04 +0100 Subject: [PATCH] Docs MCP server - Add support for configurable database path and update README with usage instructions --- docs-mcp/README.md | 28 +++++++++++++++++++++++ docs-mcp/src/Documentation.Mcp/Program.cs | 19 ++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/docs-mcp/README.md b/docs-mcp/README.md index 88ee9c7df..6f0107bb3 100644 --- a/docs-mcp/README.md +++ b/docs-mcp/README.md @@ -34,6 +34,21 @@ Alternatively, you can add a `.vscode/mcp.json` file to your workspace: } ``` +You can also add the `--database` parameter with a path to the database file to use: + +```json +{ + "servers": { + "duende-mcp": { + "type": "stdio", + "command": "dnx", + "args": ["Duende.Documentation.Mcp", "--yes", "--", "--database", "/path/to/database.db"], + "env": {} + } + } +} +``` + Open GitHub Copilot and select Agent Mode to work with the MCP server. ### JetBrains Rider @@ -56,6 +71,19 @@ Set the working directory to a path on your machine where the Duende Documentati index. Not setting the working directory will result in the MCP server failing to start because it cannot create the database file. +Alternatively, you can add the `--database` parameter with a path to the database file to use: + +```json +{ + "mcpServers": { + "duende-mcp": { + "command": "dnx", + "args": ["Duende.Documentation.Mcp", "--yes", "--", "--database", "/path/to/database.db"] + } + } +} +``` + ## Tools and Example Prompts The Duende Documentation MCP Server has several tools available: diff --git a/docs-mcp/src/Documentation.Mcp/Program.cs b/docs-mcp/src/Documentation.Mcp/Program.cs index 1dc172c04..e4b44d675 100644 --- a/docs-mcp/src/Documentation.Mcp/Program.cs +++ b/docs-mcp/src/Documentation.Mcp/Program.cs @@ -20,9 +20,24 @@ builder.Logging.AddConsole(consoleLogOptions => consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace; }); +// Determine database path +var databasePath = "mcp.db"; +if (args.Length > 0) +{ + var dbParameterIndex = args.IndexOf("--database"); + if (dbParameterIndex >= 0 && args.Length > dbParameterIndex + 1) + { + var dbPathParameter = args[dbParameterIndex + 1].Replace("\"", "", StringComparison.OrdinalIgnoreCase); + if (Path.IsPathFullyQualified(dbPathParameter)) + { + databasePath = dbPathParameter; + } + } +} + // Setup services builder.Services.AddHttpClient(); -builder.Services.AddSqlite("Data Source=mcp.db;Cache=Shared"); +builder.Services.AddSqlite("Data Source=" + databasePath + ";Cache=Shared"); builder.Services.AddHostedService(); builder.Services.AddHostedService(); @@ -73,6 +88,8 @@ async Task EnsureDb(IServiceProvider services, ILogger logger) await using var db = scope.ServiceProvider.GetRequiredService(); if (db.Database.IsRelational()) { + logger.LogInformation("Using database: {DatabasePath}", databasePath); + logger.LogInformation("Updating database..."); await db.Database.MigrateAsync(); logger.LogInformation("Updated database");