This is a sample MCP server implemented in .NET using the ModelContextProtocol C# SDK. It provides tools to store and retrieve memories categorized by type using file-based storage.
To test this MCP server from source code (locally) without using a built MCP server package, you can configure your IDE to run the project directly using dotnet run.
{
"servers": {
"MemoryMcpNet": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"<PATH TO PROJECT DIRECTORY>"
]
}
}
}Once configured, you can use the following MCP server tools provided by FileMemoryTools:
-
StoreMemory: Stores a memory in a specified category.
- Parameters:
category: The type of memory (seeMemoryCategoryenum)memory: The memory content to store
- Returns: Confirmation message with stored content
- Parameters:
-
RetrieveMemory: Retrieves all memories from a specified category.
- Parameters:
category: The type of memory
- Returns: JSON array of memory items (
Id,Content,LastUpdated)
- Parameters:
-
RemoveMemory: Removes a memory by category and ID.
- Parameters:
category: The type of memoryid: The unique ID of the memory to remove
- Returns: Confirmation message if removed, or not found message
- Parameters:
Example usage in Copilot Chat:
mcp_memorymcpnet_store_memory: Store a note in the 'Notes' category
mcp_memorymcpnet_retrieve_memory: Retrieve all reminders
mcp_memorymcpnet_remove_memory: Remove memory with ID 5 from 'History'
- Run
dotnet pack -c Releaseto create the NuGet package - Publish to NuGet.org with
dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json
Once the MCP server package is published to NuGet.org, you can configure it in your preferred IDE. Both VS Code and Visual Studio use the dnx command to download and install the MCP server package from NuGet.org.
- VS Code: Create a
<WORKSPACE DIRECTORY>/.vscode/mcp.jsonfile - Visual Studio: Create a
<SOLUTION DIRECTORY>\.mcp.jsonfile
For both VS Code and Visual Studio, the configuration file uses the following server definition:
{
"servers": {
"MemoryMcpNet": {
"type": "stdio",
"command": "dnx",
"args": [
]
}
}
}.NET MCP servers use the ModelContextProtocol C# SDK. For more information about MCP:
Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers: