ContextManager 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global ContextManager --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local ContextManager --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ContextManager&version=1.0.2
                    
nuke :add-package ContextManager --version 1.0.2
                    

ContextManager MCP

An MCP (Model Context Protocol) server that extracts structural contracts from C# source files using Roslyn. Instead of sending thousands of tokens of raw source code to an AI agent, you give it a compact JSON summary: types, methods, signatures, dependencies, line numbers — everything an agent needs to understand a file without reading it.

Why

Reading a 1 500-line C# file costs an agent thousands of tokens on every call. ContextManager turns that file into a focused JSON contract (tens of tokens) that tells the agent:

  • What types exist and their kind (class, record, interface, enum, dto)
  • The full public API surface — methods with return types, parameters, and decorators
  • Exact startLine/endLine for each method, so the agent can read only the body it needs
  • Constructor dependencies (the DI graph)
  • Base classes and interfaces
  • All using directives (the import map)
  • partial class detection, required property flags, and generic method constraints

Tools

Tool Description
inspect_file Returns a structural JSON contract for a single .cs file
inspect_context Analyzes cross-file relationships in up to 15 .cs files using the Roslyn semantic model

Installation

Prerequisites

  • .NET 8 SDK or later — verify with dotnet --version

That's it. No Python, no Node, no Docker.

1. Install the tool

dotnet tool install -g ContextManager

Verify the install:

context-manager --version

2. Add to your MCP client

Claude Code (recommended — one command):

claude mcp add context-manager -- context-manager

Claude Code (manual — add to .mcp.json in your project root):

{
  "mcpServers": {
    "context-manager": {
      "command": "context-manager"
    }
  }
}

Claude Desktop — add to claude_desktop_config.json:

{
  "mcpServers": {
    "context-manager": {
      "command": "context-manager"
    }
  }
}

Updating

dotnet tool update -g ContextManager

Output examples

inspect_file

The example below is derived from ModernCSharpFeatures.cs and shows the new fields (isPartial, isRequired, genericConstraints):

{
  "file": "ModernCSharpFeatures.cs",
  "namespace": "ContextManager.Analysis.Tests.Fixtures",
  "usings": [],
  "types": [
    {
      "name": "PartialOrderService",
      "kind": "class",
      "access": "public",
      "isPartial": true,
      "constructorDependencies": [
        { "type": "string", "name": "customerName" }
      ],
      "methods": [
        {
          "name": "Process",
          "access": "public",
          "returnType": "void",
          "startLine": 10,
          "endLine": 10,
          "parameters": [
            { "type": "string?", "name": "orderId" }
          ]
        }
      ],
      "properties": [
        { "name": "CustomerName", "type": "string?", "access": "public" }
      ]
    },
    {
      "name": "CustomerProfile",
      "kind": "class",
      "access": "public",
      "constructorDependencies": [
        { "type": "string", "name": "email" },
        { "type": "string", "name": "fullName" }
      ],
      "methods": [
        {
          "name": "GetDisplayName",
          "access": "public",
          "returnType": "string",
          "startLine": 22,
          "endLine": 22
        }
      ],
      "properties": [
        { "name": "Email",       "type": "string",  "access": "public", "isRequired": true },
        { "name": "FullName",    "type": "string",  "access": "public", "isRequired": true },
        { "name": "PhoneNumber", "type": "string?", "access": "public" }
      ]
    },
    {
      "name": "GenericProcessor",
      "kind": "class",
      "access": "public",
      "methods": [
        {
          "name": "Convert",
          "access": "public",
          "returnType": "T",
          "startLine": 28,
          "endLine": 31,
          "parameters": [
            { "type": "object", "name": "input" }
          ],
          "genericConstraints": ["T : class, new()"]
        },
        {
          "name": "Map",
          "access": "public",
          "returnType": "TResult",
          "startLine": 33,
          "endLine": 36,
          "parameters": [
            { "type": "TSource", "name": "source" }
          ],
          "genericConstraints": ["TSource : notnull", "TResult : class"]
        }
      ]
    },
    {
      "name": "OrderSummary",
      "kind": "record",
      "access": "public",
      "constructorDependencies": [
        { "type": "string",   "name": "OrderId" },
        { "type": "decimal",  "name": "Total" },
        { "type": "string?",  "name": "Notes" }
      ]
    }
  ]
}

inspect_context

The example below is a representative output matching the ContextAnalysis model shape. It shows how cross-file references are resolved when OrderService.cs and IOrderRepository.cs are analyzed together:

{
  "files": [
    {
      "file": "OrderService.cs",
      "namespace": "Zureo.Orders",
      "types": [
        {
          "name": "OrderService",
          "kind": "class",
          "base": null,
          "implements": ["IOrderService"],
          "attributes": null,
          "constructorDependencies": ["IOrderRepository"],
          "methods": ["Task<Order> GetOrderAsync(Guid id)", "Task CreateAsync(CreateOrderRequest request)"]
        }
      ]
    },
    {
      "file": "IOrderRepository.cs",
      "namespace": "Zureo.Orders",
      "types": [
        {
          "name": "IOrderRepository",
          "kind": "interface",
          "base": null,
          "implements": null,
          "attributes": null,
          "constructorDependencies": null,
          "methods": ["Task<Order> GetOrderAsync(Guid id)", "Task SaveAsync(Order order)"]
        }
      ]
    }
  ],
  "references": [
    {
      "from": "OrderService",
      "to": "IOrderRepository",
      "via": "constructor",
      "resolvedFile": "IOrderRepository.cs"
    }
  ],
  "unresolved": ["IOrderService"]
}

Build & test

dotnet restore
dotnet build
dotnet test
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.1.9 51 9/14/2026
1.1.8 100 6/30/2026
1.1.7 77 6/30/2026
1.1.6 82 6/10/2026
1.1.5 81 6/9/2026
1.1.4 74 5/26/2026
1.1.3 63 5/26/2026
1.1.2 62 5/26/2026
1.1.1 59 5/26/2026
1.0.3 68 4/29/2026
1.0.2 76 4/19/2026
1.0.1 64 4/19/2026