LocalMcpServer
About
LocalMcpServer is a demonstration implementation of a Model Context Protocol (MCP) server built with .NET 9.0. It uses STDIO transport to provide tools—such as a time retrieval tool and a NuGet package interface lookup service—that can be invoked by compatible MCP clients…
Details
- Author
- DimonSmart
- Downloads
- 146
- Categories
- Other
Jump to
- Implementation of a basic MCP server using the ModelContextProtocol library
- Uses STDIO transport for client-server communication
- Includes a sample TimeTool that returns the current server time
- Provides an InterfaceLookupService to retrieve C# interface definitions from NuGet packages
- Built with .NET 9.0 and the .NET Generic Host
- Automatically discovers and registers tools from the assembly
Clone the repository, build the application with dotnet build, then run it with dotnet run. The server communicates over standard input/output, so you must connect a compatible MCP client—such as OllamaChat—to interact with its tools.
LocalMcpServer
A demonstration implementation of a server supporting the Model Context Protocol (MCP).
Overview
This application demonstrates how to create a simple MCP server using the ModelContextProtocol library. The server provides tools that can be used by MCP clients, showcasing the interaction between client and server using STDIO transport.
This demo can be used in conjunction with the OllamaChat application, a local chat client for OLLAMA.
Features
- Implementation of a basic MCP server
- Uses STDIO for client communication
- Includes a sample tool (TimeTool) that returns the current server time
- Built with .NET 9.0
Prerequisites
- .NET 9.0 SDK or higher
- A compatible MCP client for testing (for example, OllamaChat)
Getting Started
1. Clone this repository
2. Build the application:
dotnet build
3. Run the server:
dotnet run
Project Structure
- Program.cs - The main entry point that configures and runs the MCP server
- TimeTool.cs - A sample tool implementation that provides time-related functionality
Implementation Details
The server is configured using the .NET Generic Host with the following components:
- Console logging configured to trace level
- Registration of the MCP server with STDIO transport
- Automatic discovery and registration of tools from the assembly
Available Tools
TimeTool
- GetCurrentTime() - Returns the current server time in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ)
InterfaceLookupService
- GetInterfaceDefinition(packageId, interfaceName, version?) - Extracts and returns the C# interface definition from a specified NuGet package
- ListInterfaces(packageId, version?) - Lists all public interfaces available in a specified NuGet package. Returns package ID, package version and the list of interfaces
Technical Details
The application uses the ModelContextProtocol library (version 0.1.0-preview.9), which provides infrastructure for creating MCP-compatible servers. The server is configured to use standard input/output for communication with clients.
Integration with OllamaChat
This demo server can be integrated with the OllamaChat application, which is a local chat client for OLLAMA. By connecting this MCP server to OllamaChat, you can demonstrate the capabilities of tool-using language models in a local environment.
About the MCP Protocol
Model Context Protocol (MCP) is a protocol designed to standardize communication between language models and external tools. It allows models to call functions, retrieve information, and interact with external systems through a unified interface.
License
See the LICENSE file for license information.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



