Skip to content

Commit a6f08c1

Browse files
authored
Merge pull request #4 from asklar/copilot/fix-3
Publish McpExtract as a .NET Tool for Global Installation
2 parents 4be4c51 + a426cf3 commit a6f08c1

File tree

11 files changed

+209
-50
lines changed

11 files changed

+209
-50
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '8.0.x'
20+
21+
- name: Restore dependencies
22+
run: dotnet restore src/McpExtract.csproj
23+
24+
- name: Build
25+
run: dotnet build src/McpExtract.csproj --configuration Release --no-restore
26+
27+
- name: Test
28+
run: dotnet test --configuration Release --no-build --verbosity normal
29+
30+
- name: Pack
31+
run: dotnet pack src/McpExtract.csproj --configuration Release --no-build --output ./artifacts
32+
33+
- name: Upload artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: nuget-package
37+
path: ./artifacts/*.nupkg

.github/workflows/dotnet.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v4
2121
with:
22-
dotnet-version: 9.0.x
22+
dotnet-version: 8.0.x
2323
- name: Restore dependencies
24-
run: dotnet restore
24+
run: dotnet restore src/McpExtract.csproj
2525
- name: Build
26-
run: dotnet build --no-restore
26+
run: dotnet build src/McpExtract.csproj --no-restore
2727
- name: Test
2828
run: dotnet test --no-build --verbosity normal
2929
- name: Build TestMcp
3030
run: dotnet build TestMcp/TestMcp.csproj
3131
- name: Print TestMcp DXT Output
32-
run: dotnet run --project McpExtract.csproj -- TestMcp/bin/Debug/net9.0/TestMcp.dll --format dxt
32+
run: dotnet run --project src/McpExtract.csproj -- TestMcp/bin/Debug/net8.0/TestMcp.dll --format dxt

.github/workflows/publish-tool.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish .NET Tool
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '8.0.x'
19+
20+
- name: Restore dependencies
21+
run: dotnet restore src/McpExtract.csproj
22+
23+
- name: Build
24+
run: dotnet build src/McpExtract.csproj --configuration Release --no-restore
25+
26+
- name: Test
27+
run: dotnet test --configuration Release --no-build --verbosity normal
28+
29+
- name: Pack
30+
run: dotnet pack src/McpExtract.csproj --configuration Release --no-build --output ./artifacts
31+
32+
- name: Publish to NuGet
33+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

McpExtract.csproj

Lines changed: 0 additions & 23 deletions
This file was deleted.

McpExtract.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 17
33
VisualStudioVersion = 17.5.2.0
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpExtract", "McpExtract.csproj", "{2855063D-7553-B24A-68A8-B6A4DF1CB640}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpExtract", "src\McpExtract.csproj", "{2855063D-7553-B24A-68A8-B6A4DF1CB640}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22

33
A command line tool that extracts Model Context Protocol (MCP) tool metadata from .NET assemblies and outputs it as JSON, Python function definitions, or DXT manifests.
44

5+
## Installation
6+
7+
### Install as a .NET Global Tool
8+
9+
McpExtract is available as a .NET global tool and can be installed from NuGet:
10+
11+
```bash
12+
dotnet tool install -g McpExtract.Tool
13+
```
14+
15+
Once installed, you can run the tool from anywhere using:
16+
17+
```bash
18+
mcp-extract --help
19+
```
20+
21+
### Update to Latest Version
22+
23+
To update to the latest version:
24+
25+
```bash
26+
dotnet tool update -g McpExtract.Tool
27+
```
28+
29+
### Uninstall
30+
31+
To uninstall the tool:
32+
33+
```bash
34+
dotnet tool uninstall -g McpExtract.Tool
35+
```
36+
37+
### Local Development Installation
38+
39+
For local development, you can install from source:
40+
41+
```bash
42+
git clone https://github.com/asklar/McpExtract.git
43+
cd McpExtract
44+
dotnet pack
45+
dotnet tool install -g McpExtract.Tool --add-source ./bin/Release
46+
```
47+
548
## Why This Tool Matters
649

750
This tool bridges a critical gap between MCP server development and AI model training workflows:
@@ -54,34 +97,58 @@ It outputs structured JSON, Python, or DXT manifest formats, containing details
5497
```bash
5598
# In your CI/CD pipeline
5699
dotnet build MyMcpServer.csproj
57-
McpExtract bin/Release/net9.0/MyMcpServer.dll --output tools.json
58-
McpExtract bin/Release/net9.0/MyMcpServer.dll --output training_functions.py --format python
59-
McpExtract bin/Release/net9.0/MyMcpServer.dll --output manifest.json --format dxt
100+
mcp-extract bin/Release/net8.0/MyMcpServer.dll --output tools.json
101+
mcp-extract bin/Release/net8.0/MyMcpServer.dll --output training_functions.py --format python
102+
mcp-extract bin/Release/net8.0/MyMcpServer.dll --output manifest.json --format dxt
60103

61104
# Training pipeline can now use tools.json for metadata and training_functions.py as reference
62105
# DXT systems can use manifest.json for MCP server distribution and integration
63106
```
64107

65108
## Usage
66109

110+
### Quick Start
111+
112+
After installing the global tool:
113+
114+
```bash
115+
# Show help and version information
116+
mcp-extract --help
117+
mcp-extract --version
118+
119+
# Basic usage - analyze a .NET assembly and output JSON to console
120+
mcp-extract MyMcpServer.dll
121+
122+
# Output JSON to file
123+
mcp-extract MyMcpServer.dll --output tools.json
124+
125+
# Generate Python function definitions
126+
mcp-extract MyMcpServer.dll --format python
127+
128+
# Generate DXT manifest
129+
mcp-extract MyMcpServer.dll --format dxt
130+
```
131+
132+
### Detailed Usage
133+
67134
```bash
68135
# Basic usage - output JSON to console
69-
McpExtract <assembly-path>
136+
mcp-extract <assembly-path>
70137

71138
# Output JSON to file
72-
McpExtract <assembly-path> --output <output-file>
139+
mcp-extract <assembly-path> --output <output-file>
73140

74141
# Output Python function definitions
75-
McpExtract <assembly-path> --format python
142+
mcp-extract <assembly-path> --format python
76143

77144
# Output Python to file
78-
McpExtract <assembly-path> --output tools.py --format python
145+
mcp-extract <assembly-path> --output tools.py --format python
79146

80147
# Output DXT manifest
81-
McpExtract <assembly-path> --format dxt
148+
mcp-extract <assembly-path> --format dxt
82149

83150
# Output DXT manifest to file
84-
McpExtract <assembly-path> --output manifest.json --format dxt
151+
mcp-extract <assembly-path> --output manifest.json --format dxt
85152
```
86153

87154
### Command Line Options
@@ -95,16 +162,16 @@ McpExtract <assembly-path> --output manifest.json --format dxt
95162

96163
```bash
97164
# Analyze an MCP server assembly and output JSON to console
98-
McpExtract MyMcpServer.dll
165+
mcp-extract MyMcpServer.dll
99166

100167
# Analyze and save JSON to file
101-
McpExtract MyMcpServer.dll --output tools.json
168+
mcp-extract MyMcpServer.dll --output tools.json
102169

103170
# Generate Python function definitions
104-
McpExtract MyMcpServer.dll --format python
171+
mcp-extract MyMcpServer.dll --format python
105172

106173
# Generate Python and save to file
107-
McpExtract MyMcpServer.dll --output tools.py --format python
174+
mcp-extract MyMcpServer.dll --output tools.py --format python
108175
```
109176

110177
## Output Formats
@@ -219,23 +286,25 @@ The analyzer recognizes and properly handles:
219286
- Task and Task<T> return types
220287
- Custom classes and structures
221288

222-
## Building
289+
## Requirements
290+
291+
- .NET 8.0 or later runtime for running the tool
292+
- Target assembly must be built with .NET Framework 4.6.1+ or .NET Core/5+
293+
294+
## Building from Source
223295

224296
```bash
297+
git clone https://github.com/asklar/McpExtract.git
298+
cd McpExtract
225299
dotnet build
226300
```
227301

228-
For AOT publication:
302+
To create a release package:
229303

230304
```bash
231-
dotnet publish -c Release
305+
dotnet pack
232306
```
233307

234-
## Requirements
235-
236-
- .NET 9.0 or later
237-
- Target assembly must be built with .NET Framework 4.6.1+ or .NET Core/5+
238-
239308
## Notes
240309

241310
- The tool loads the target assembly using reflection, so it should be compatible with the current runtime

TestMcp/TestMcp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

src/McpExtract.csproj

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<PublishAot>false</PublishAot>
9+
<InvariantGlobalization>true</InvariantGlobalization>
10+
<TrimMode>link</TrimMode>
11+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
12+
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
13+
<AssemblyName>McpExtract</AssemblyName>
14+
<RootNamespace>McpExtract</RootNamespace>
15+
16+
<!-- Global Tool Configuration -->
17+
<PackAsTool>true</PackAsTool>
18+
<ToolCommandName>mcp-extract</ToolCommandName>
19+
20+
<!-- Package Metadata -->
21+
<PackageId>McpExtract.Tool</PackageId>
22+
<Version>1.0.0</Version>
23+
<Authors>asklar</Authors>
24+
<Description>A command line tool that extracts Model Context Protocol (MCP) tool metadata from .NET assemblies and outputs it as JSON, Python function definitions, or DXT manifests.</Description>
25+
<PackageProjectUrl>https://github.com/asklar/McpExtract</PackageProjectUrl>
26+
<RepositoryUrl>https://github.com/asklar/McpExtract</RepositoryUrl>
27+
<RepositoryType>git</RepositoryType>
28+
<PackageTags>MCP;Model Context Protocol;CLI;Tool;Analysis;JSON;Python;DXT</PackageTags>
29+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
30+
<PackageReadmeFile>README.md</PackageReadmeFile>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
35+
<PackageReference Include="System.Reflection.Metadata" Version="8.0.0" />
36+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<None Include="../README.md" Pack="true" PackagePath="\"/>
41+
</ItemGroup>
42+
43+
</Project>

0 commit comments

Comments
 (0)