Commit 91e2b0b5 authored by shrabbit's avatar shrabbit
Browse files

初始化

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
 No newline at end of file

McpBase.slnx

0 → 100644
+3 −0
Original line number Diff line number Diff line
<Solution>
  <Project Path="src/McpBase.McpServer/McpBase.McpServer.csproj" />
</Solution>
+22 −0
Original line number Diff line number Diff line
{
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
  "description": "<your description here>",
  "name": "io.github.<your GitHub username here>/<your repo name>",
  "version": "0.1.0-beta",
  "packages": [
    {
      "registryType": "nuget",
      "identifier": "<your package ID here>",
      "version": "0.1.0-beta",
      "transport": {
        "type": "stdio"
      },
      "packageArguments": [],
      "environmentVariables": []
    }
  ],
  "repository": {
    "url": "https://github.com/<your GitHub username here>/<your repo name>",
    "source": "github"
  }
}
+40 −0
Original line number Diff line number Diff line
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net10.0</TargetFramework>
        <RuntimeIdentifiers>win-x64;win-arm64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64</RuntimeIdentifiers>
        <OutputType>Exe</OutputType>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>

        <!-- Set up the NuGet package to be an MCP server -->
        <PackAsTool>true</PackAsTool>
        <PackageType>McpServer</PackageType>

        <!-- Set up the MCP server to be a self-contained application that does not rely on a shared framework -->
        <SelfContained>true</SelfContained>
        <PublishSelfContained>true</PublishSelfContained>

        <!-- Set up the MCP server to be a single file executable -->
        <PublishSingleFile>true</PublishSingleFile>

        <!-- Set recommended package metadata -->
        <PackageReadmeFile>README.md</PackageReadmeFile>
        <PackageId>SampleMcpServer</PackageId>
        <PackageVersion>0.1.0-beta</PackageVersion>
        <PackageTags>AI; MCP; server; stdio</PackageTags>
        <Description>An MCP server using the MCP C# SDK.</Description>
    </PropertyGroup>

    <!-- Include additional files for browsing the MCP server. -->
    <ItemGroup>
        <None Include=".mcp\server.json" Pack="true" PackagePath="/.mcp/"/>
        <None Include="README.md" Pack="true" PackagePath="/"/>
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1"/>
        <PackageReference Include="ModelContextProtocol" Version="1.2.0"/>
    </ItemGroup>

</Project>
+16 −0
Original line number Diff line number Diff line
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

var builder = Host.CreateApplicationBuilder(args);

// Configure all logs to go to stderr (stdout is used for the MCP protocol messages).
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);

// Add the MCP services: the transport to use (stdio) and the tools to register.
builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithTools<RandomNumberTools>();

await builder.Build().RunAsync();
 No newline at end of file
Loading