Plugin System¶
dotnet-mcp-server has a drop-in plugin system. You can add your own tools to the server without forking or modifying the core project.
How It Works¶
- You write a .NET class library that implements the
IToolinterface - You build it to a DLL
- You copy the DLL into the
plugins/directory - The server discovers and loads it automatically on the next start
The server scans for DLLs in the plugins/ folder at startup, instantiates any class implementing ITool, and registers them alongside the built-in tools. Your plugin tool appears in tools/list exactly like a built-in.
Plugin vs. Built-in Tool¶
| Built-in tool | Plugin tool | |
|---|---|---|
| Where code lives | src/McpServer/Tools/ |
Your own repository |
| How to install | Always included | Copy DLL to plugins/ |
| Requires server fork | No (it's in the server) | No |
| Requires server restart | N/A | Yes, once after installing |
| Config access | Via IOptions<T> |
Via PluginContext.GetConfig() |
Plugin Directory Location¶
| Install method | Plugins directory |
|---|---|
| Global tool (Windows) | %APPDATA%\dotnet-mcp-server\plugins\ |
| Global tool (Linux/macOS) | ~/.config/dotnet-mcp-server/plugins\ |
| Clone & build | plugins\ next to appsettings.json |
You can override the directory via appsettings.json:
Getting Started¶
The fastest way to write a plugin is with the project template:
Plugin Configuration¶
Pass values to your plugin via the Plugins.Config section in appsettings.json:
{
"Plugins": {
"Config": {
"api_base_url": "https://api.example.com",
"api_key": "your-key-here"
}
}
}
Read them in your plugin using the PluginContext constructor: