DotNetSearch

io.github.puneethdc99v1.0.1更新於 Oct 5, 2026

Token-efficient MCP search server for AI agents across local directories.

已驗證STDIO僅桌面Developer ToolsFiles & Storage

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓助理能以節省 token 的方式搜尋程式碼庫、反編譯 .NET 型別,並詳細讀取與檢視 PDF。

功能
DotNetSearch 提供程式碼搜尋工具(search、search_related),只回傳符合的行而非整個檔案,另有 read_file 與 compress_code 可降低上下文用量。它也提供 PDF 工具:read_pdf_text、get_pdf_info、render_pdf_page_as_image、extract_pdf_images、get_pdf_bookmarks、get_pdf_form_fields、extract_pdf_attachments 與 get_pdf_hyperlinks。decompile_type 可從專案參考的 NuGet 組件回傳 .NET 型別的 C# 定義。
適用情境
適合助理在本機程式碼庫中工作、希望降低搜尋與讀取檔案 token 用量時;需要在沒有原始碼的情況下了解第三方 .NET API 時;或需要從 PDF 結構化擷取文字、書籤、表單、圖片與連結時。
執行需求
以本機 stdio 程序在使用者機器上執行(僅桌面端)。需下載對應平台的可執行檔;執行環境已內嵌,無需安裝 .NET。需將其路徑加入 MCP 用戶端設定。decompile_type 要求 .NET 專案至少已建置過一次。
安裝前請注意
工具會讀取本機檔案與目錄,多個 PDF 工具會將檔案寫入磁碟(算繪的 PNG、擷取的圖片與附件)。compress_code 可能破壞對縮排敏感的語言(例如 Python、YAML、HAML、Makefile),也可能改變多行字串常值內部的空白。未宣告任何憑證或網路存取。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 DotNetSearch,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

DotNetSearch — MCP Search & PDF Server

DotNetSearch is a self-contained MCP (Model Context Protocol) server that empowers GitHub Copilot, Claude, Cursor, and other AI agents with high-performance codebase search, NuGet package decompilation, whitespace token reduction, and deep PDF document reading and analysis:

Key Tools Overview

CategoryToolPurpose
Code SearchsearchFind files and lines matching a keyword or natural-language query — returns only matching lines (~110 tokens vs ~2500 for a full file read)
Code Searchsearch_relatedFind code chunks structurally similar to a known location — ideal for discovering callers, implementations, or patterns
Decompilationdecompile_typeDecompile any .NET type from referenced NuGet package assemblies — returns the full C# class definition without needing the source code
Optimizationcompress_codeReduce C# code indentation from 4-space to 1-space per indent level and remove blank lines — saves 10–20% tokens with zero semantic change
File Readingread_fileRead a file from disk and optionally return a specific line range — useful after search when you need full file context
PDF Readingread_pdf_textExtract clean, structured text page-by-page or across targeted page ranges from any PDF document
PDF Readingget_pdf_infoInspect PDF metadata, total page count, per-page dimensions, author, subject, creation date, and structure
PDF Visualsrender_pdf_page_as_imageRasterize any PDF page into a high-resolution PNG image at custom DPI — ideal for inspecting charts, diagrams, tables, and scanned documents
PDF Visualsextract_pdf_imagesExtract embedded raster images from PDF pages and save to disk with pixel coordinates
PDF Structureget_pdf_bookmarksExtract the hierarchical table of contents, bookmarks, and document outline with target page links
PDF Formsget_pdf_form_fieldsRead interactive AcroForm form fields (text boxes, checkboxes, radio buttons, dropdowns) and their values
PDF Assetsextract_pdf_attachmentsExtract embedded file attachments from PDF documents and save them to disk
PDF Linksget_pdf_hyperlinksExtract all clickable web URLs, internal page jumps, and external document links with bounding boxes

Instead of reading full files (~2500 tokens each), the agent gets back only the matching lines (~110 tokens) — saving up to 98% of context window per query. For files that must be read in full, use compress_code first to strip whitespace overhead and save an additional 10–20% of tokens. For PDF documentation, technical manuals, and specifications, dedicated tools extract targeted text, images, and tables without overwhelming the model context window.


Step 1 — Download the executable

Go to the latest release and download the file for your platform:

PlatformFile to download
Windows x64DotNetSearch-win-x64.exe
Linux x64DotNetSearch-linux-x64
macOS ARM64DotNetSearch-osx-arm64

No .NET installation required. The runtime is bundled inside the executable.

Save it somewhere permanent, e.g.:

  • Windows: C:\Tools\DotNetSearch.exe
  • Linux/macOS: /usr/local/bin/DotNetSearch

On Linux/macOS, make it executable:

bash
chmod +x /usr/local/bin/DotNetSearch

Step 2 — Add to your MCP config

Open (or create) your global MCP config file:

ClientConfig file location
Visual Studio%USERPROFILE%\.mcp.json
VS Code + Copilot%USERPROFILE%\.mcp.json
Claude Desktop%APPDATA%\Claude\claude_desktop_config.json
Cursor%USERPROFILE%\.cursor\mcp.json

Windows configuration

Add this to the servers section:

json
{  "servers": {    "DotNetSearch": {      "type": "stdio",      "command": "C:\\Tools\\DotNetSearch.exe"    }  }}

Linux / macOS configuration

json
{  "servers": {    "DotNetSearch": {      "type": "stdio",      "command": "/usr/local/bin/DotNetSearch"    }  }}

If you already have other servers in the file, just add the "DotNetSearch" block inside the existing "servers" object.


Step 3 — Verify it is active

Visual Studio / VS Code:

  1. Open GitHub Copilot Chat
  2. Switch to Agent Mode
  3. Click the wrench / Select Tools icon
  4. Confirm the DotNetSearch tools appear in the list and are enabled:
    • Code & Navigation: search, search_related, decompile_type, compress_code, read_file
    • PDF Document Inspection: read_pdf_text, get_pdf_info, render_pdf_page_as_image, extract_pdf_images, get_pdf_bookmarks, get_pdf_form_fields, extract_pdf_attachments, get_pdf_hyperlinks

Step 4 — Update your Copilot instructions

To make Copilot automatically prefer DotNetSearch over built-in file reading, add the instructions below to your Copilot instructions file. There are two places you can put this — repo-level (affects only that repo) or global (affects all repos).


Option A — Repo-level instructions (recommended)

File location:

<your-repo-root>\.github\copilot-instructions.md

This file is read by GitHub Copilot for every conversation in that repository. It is the recommended place if you want DotNetSearch to be preferred only for a specific project.

How to find or create it:

  • Navigate to your repository root folder
  • Look for a .github subfolder — if it doesn't exist, create it
  • Inside .github, look for copilot-instructions.md — if it doesn't exist, create the file

Option B — Global instructions (applies to all repos)

File location:

ClientGlobal instructions file
Visual Studio%APPDATA%\Microsoft\VisualStudio\Copilot\copilot-instructions.md
VS Code + Copilot%USERPROFILE%\.github\copilot-instructions.md

How to find or create it:

  • Open the path above in File Explorer (paste into the address bar)
  • If the folder doesn't exist, create it
  • If copilot-instructions.md doesn't exist in the folder, create the file

Note: If you add instructions to both files, Copilot merges them — both will be active at the same time.


Instructions to add

Paste the following into whichever file you chose above:

markdown
## Search PreferenceWhen searching for code, symbols, or text in this repository, always preferthe `DotNetSearch` MCP tool (`search` and `search_related`) over reading fullfiles or using built-in workspace search. DotNetSearch returns only matchinglines and is significantly more token-efficient (~98% fewer tokens per query).Do not call DotNetSearch tools in parallel — run one search at a time.
## PDF Document ReadingWhen reading, analyzing, or searching PDF documents:- Always prefer `read_pdf_text` and `get_pdf_info` over raw file operations.- First call `get_pdf_info` to inspect total pages and document metadata.- Call `read_pdf_text` with specific page ranges (`startPage`, `endPage`) to avoid token overflow.- If the PDF contains visual charts, flowcharts, architectural diagrams, or scanned pages, use `render_pdf_page_as_image` to rasterize the page.- For interactive PDF forms, use `get_pdf_form_fields` to extract user inputs.
## NuGet Type InspectionWhen the user asks about a third-party or NuGet type and the source code is notavailable in the workspace, use the `DotNetSearch` MCP tool `decompile_type` todecompile the type from the project's referenced assemblies. Pass the short orfully qualified type name and the absolute path to the .csproj file. The projectmust have been built at least once before calling this tool.
## Code CompressionWhen reading source files to minimize context window usage, use the`DotNetSearch` MCP tool `compress_code` — BUT ONLY for the following fully-safelanguages where indentation is cosmetic and braces/keywords define scope:
  C#, Java, JavaScript, TypeScript, C, C++, Kotlin, Swift, Rust, Scala,  PHP, Ruby, CSS, SCSS, Less, JSON, XML
NEVER call `compress_code` on any other language. In particular, NEVER use it onPython, YAML, CoffeeScript, Pug/Jade, HAML, or Makefile — these areindentation-sensitive and compression WILL silently corrupt the file structure.
Before calling `compress_code`, check the file extension:- Allowed:  .cs .java .js .ts .jsx .tsx .kt .swift .rs .scala .php .rb .css .scss .less .json .xml .c .cpp .h- Blocked:  .py .yaml .yml .coffee .pug .jade .haml  (and Makefiles with no extension)
Pass the absolute file path. For JavaScript/TypeScript projects using 2-spaceindentation, set `sourceIndentSize=2`.

Step 5 — You're done

No special commands or workflow changes are needed. Just continue your normal coding tasks in Copilot Agent Mode — DotNetSearch will be used automatically whenever Copilot needs to search your codebase or inspect PDF documents.

Over time you will notice a reduction in token usage per conversation. This is because DotNetSearch returns only the matching lines (typically ~110 tokens) instead of full file contents (~2500 tokens), saving up to 98% of context window per search operation.


Tool reference

search

Searches a local directory for files whose content matches a keyword or natural-language query. Uses BM25 ranking with CamelCase and snake_case token expansion.

ParameterTypeDefaultDescription
querystringrequiredKeyword, identifier, or natural-language phrase
repostringrequiredAbsolute or relative path to the directory to search
top_kint5Max results to return (1–100)
context_linesint0Lines of context above/below each match (0–5)

search_related

Finds code chunks structurally similar to a specific location in a file. Use after search to explore related implementations, callers, or patterns.

ParameterTypeDefaultDescription
file_pathstringrequiredPath to the file as returned by a prior search result
lineintrequiredLine number (1-indexed) from a prior search result
repostringrequiredAbsolute or relative path to the directory to search
top_kint5Number of similar chunks to return (1–100)

read_file

Reads a text file from disk and returns its contents. Use it after search when you already know the target file and need the full context. Supports an absolute or relative path plus optional start_line and end_line range arguments.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the file to read
start_lineint11-based line number to start reading from
end_lineint01-based line number to stop reading at (0 = read to end)

read_pdf_text

Extracts clean, formatted text from a PDF file with page markers. Ideal for documentation, technical specifications, papers, and architecture guides. Supports whole-document extraction or targeted page ranges.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file
startPageint11-based page number to begin extracting text from
endPageint01-based page number to stop extracting text at (0 = read through the last page)

get_pdf_info

Retrieves comprehensive metadata and physical layout information about a PDF file without reading its full text content. Use this first to plan targeted extractions.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file

Returns: Total page count, dimensions per page (widthPt, heightPt), document title, author, subject, keywords, creator, producer, creation date, and modification date.


render_pdf_page_as_image

Rasterizes a specific PDF page into a high-resolution PNG image on disk. Essential for pages with complex graphical diagrams, architectural flowcharts, schematics, tables, or scanned documents where raw text extraction is insufficient.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file
pageNumberint11-based index of the page to render
dpiint150Render resolution in DPI (e.g. 72 = draft, 150 = standard, 300 = print/high-res)

Returns: Path to the rendered .png image and image pixel dimensions.


extract_pdf_images

Extracts all embedded raster images (e.g., photos, diagrams, embedded JPEGs/PNGs) from a PDF page and saves them directly to disk.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file
pageNumberint01-based page number (0 = extract embedded images across all pages)
outputDirectorystringnullFolder to save images into (defaults to <pdf-folder>/<pdf-name>_images/)

get_pdf_bookmarks

Extracts the hierarchical bookmark outline (Table of Contents tree) from a PDF. Helps agents understand the complete document structure before requesting specific chapters or pages.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file

Returns: Recursive tree of bookmarks with titles and target destination page numbers.


get_pdf_form_fields

Reads all interactive AcroForm form fields embedded in a PDF document.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file

Returns: List of form fields with field names, field types (textbox, checkbox, combobox, radio button), and current values.


extract_pdf_attachments

Extracts files embedded directly inside the PDF catalog (e.g., attached source code, sample data, schemas, or companion files) and writes them to disk.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file
outputDirectorystringnullDirectory to save extracted attachments into

get_pdf_hyperlinks

Extracts all hyperlinks and clickable annotations present on PDF pages.

ParameterTypeDefaultDescription
pathstringrequiredAbsolute or relative path to the PDF file
pageNumberint01-based page number (0 = extract links from all pages)

Returns: URL targets, destination page jumps, and bounding coordinates for each hyperlink.


decompile_type

Decompiles a .NET type (class, interface, enum, struct, or delegate) from NuGet package assemblies referenced by a .NET project. Useful when you need to understand third-party APIs without source code.

ParameterTypeDefaultDescription
typeNamestringrequiredShort name (Session) or fully qualified name (Opc.Ua.Client.Session)
projectPathstringrequiredAbsolute path to the .csproj that references the NuGet package
maxResultsint1Max matches to return when the name is ambiguous across assemblies

Note: The project must be built at least once so the bin\ output folder is populated with NuGet assemblies.


compress_code

Reduces code indentation from 4-space (or configurable) to 1-space per indent level and removes blank lines. Saves 10–20% tokens with zero semantic change — safe because brace-scoped and keyword-scoped languages treat indentation as cosmetic. Accepts either an absolute file path or a raw code string. Returns compressed code plus metrics: originalLength, compressedLength, savingsPercent, and line counts.

✅ Safe for (brace-scoped / keyword-scoped): C#, Java, JavaScript, TypeScript, C, C++, Kotlin, Swift, Rust, Scala, PHP, Ruby, CSS, SCSS, Less, JSON, XML

❌ Do NOT use on (indentation-sensitive — will corrupt code): Python, YAML, CoffeeScript, Pug/Jade, HAML, Makefile

⚠️ Conditional:

  • Go — safe for LLM reading; uses tabs natively so set sourceIndentSize=4 (tab width). Round-trip compilation would need gofmt.
  • Markdown — avoid; 4-space indent = code block in Markdown spec.
  • JavaScript/TypeScript — set sourceIndentSize=2 for 2-space projects.
  • Multi-line string literals (C# verbatim strings, Java """, JS template literals) — internal whitespace is also reduced. Code is still readable by an LLM but not round-trip safe for strings that depend on exact internal indentation.
ParameterTypeDefaultDescription
filePathstringnullAbsolute path to the source file to compress. Provide either this or code.
codestringnullRaw source code string to compress. Used when filePath is not provided.
sourceIndentSizeint4Number of spaces that represent one indent level in the source. Set to 2 for JS/TS/Ruby/Scala projects.
targetIndentSizeint1Number of spaces to use per indent level in the output.

Supported file types

.pdf .cs .ts .js .jsx .tsx .json .md .txt .xml .yaml .yml .html .css .py .java .cpp .c .h .go .rs .sh .ps1 .psm1 .psd1 .toml .ini .env .config .csproj .props .targets .razor .vue .svelte


License

MIT — see LICENSE for details.

來源:README.md,提交 837d79e

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v1.0.1最新Oct 5, 2026