Skip to content

wullemsb/ProjectDocsServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProjectDocsServer

A Model Context Protocol (MCP) server that exposes project documentation and resources through a standardized protocol. This server demonstrates how to create an MCP server using .NET 9 and C# that provides various types of resources including static content, dynamic file access, project statistics, and progress-reporting operations.

What is MCP?

The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). This project implements an MCP server that exposes project-related resources that can be consumed by MCP clients.

Features

This MCP server exposes the following resources:

  • project://readme - Returns the project README content
  • project://config - Returns project configuration as JSON
  • project://file/{path} - Returns the content of a file at the specified path (with security restrictions)
  • project://logs/{date} - Returns application logs for a specific date (yyyy-MM-dd format)
  • project://files/list - Returns a list of all files in the project
  • project://stats - Returns project statistics (file counts, size, timestamp)
  • project://analyze - Performs deep analysis of the project with progress reporting
  • project://diagram - Returns a project architecture diagram (PNG image)

Technology Stack

  • .NET 9.0 - Target framework
  • C# 13.0 - Programming language
  • ModelContextProtocol (v0.4.1-preview.1) - Core MCP protocol implementation
  • ModelContextProtocol.AspNetCore (v0.4.1-preview.1) - ASP.NET Core integration
  • Microsoft.Extensions.Hosting - Host builder and dependency injection

Project Structure

ProjectDocsServer/
├── Program.cs              # Entry point and MCP server configuration
├── ProjectResource.cs      # Resource implementations
├── ProjectDocsServer.csproj # Project file
└── README.md              # This file

Building the Project

dotnet build

Running the Server

dotnet run

The server runs using STDIO transport, which means it communicates through standard input/output. All logging is directed to stderr to avoid interfering with the MCP protocol communication.

Testing with Model Context Inspector

The Model Context Inspector is a developer tool for testing and debugging MCP servers. Here's how to test this server:

Installation

Install the Model Context Inspector globally:

npm install -g @modelcontextprotocol/inspector

Testing the Server

  1. Start the Inspector:
npx @modelcontextprotocol/inspector dotnet run
  1. Configure the Server Connection:

In the Inspector UI, add your server configuration:

{
  "command": "dotnet",
  "args": ["run", "--project", "path/to/ProjectDocsServer/ProjectDocsServer.csproj"]
}

Or if you've already built the project:

{
  "command": "dotnet",
  "args": ["path/to/ProjectDocsServer/bin/Debug/net9.0/ProjectDocsServer.dll"]
}
  1. Connect to the Server:

Click "Connect" in the Inspector interface. You should see the server initialize and the available resources listed.

Testing Resources

Once connected, you can test each resource:

Test Static Resources

  • README: Request project://readme to get the project documentation
  • Config: Request project://config to get configuration JSON
  • Stats: Request project://stats to get project statistics

Test Dynamic Resources

  • File Access: Request project://file/Program.cs to read the Program.cs file
  • Logs: Request project://logs/2024-01-15 to get logs for January 15, 2024
  • File List: Request project://files/list to see all project files

About

Example implementation of an MCP server that uses MCP resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages