Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@

<Content
Include="templates\**\*"
Exclude="templates\**\*.csproj-in"
Exclude="
templates\**\*.csproj-in;
templates\**\*.fsproj-in
"
PackagePath="content" />

<!-- C# template transform -->
<TemplateContent
Include="templates\**\*.csproj-in"
ChangeExtension=".csproj"
PackagePath="content" />

<!-- F# template transform -->
<TemplateContent
Include="templates\**\*.fsproj-in"
ChangeExtension=".fsproj"
PackagePath="content" />

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"description": "A project template for creating a Model Context Protocol (MCP) server using C# and the ModelContextProtocol package.",
"shortName": "mcpserver",
"defaultName": "McpServer",
"groupIdentity": "McpServer",
"sourceName": "McpServer-CSharp",
"preferNameDirectory": true,
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"Transport": {
"longName": "transport",
"shortName": "t"
},
"SelfContained": {
"longName": "self-contained",
"shortName": ""
},
Comment on lines +8 to +11
"Framework": {
"longName": "framework"
},
"httpPort": {
"isHidden": true
},
"httpsPort": {
"isHidden": true
}
},
"usageExamples": [
""
]
Comment on lines +22 to +24
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/ide.host",
"order": 0,
"icon": "ide/icon.ico",
"symbolInfo": [
{
"id": "Transport",
"isVisible": true
},
{
"id": "SelfContained",
"isVisible": true
}
]
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [
"Common",
"AI",
"MCP"
],
"identity": "Microsoft.McpServer.ProjectTemplates.McpServer.FSharp",
"name": "MCP Server App",
"description": "A project template for creating a Model Context Protocol (MCP) server using F# and the ModelContextProtocol package.",
"shortName": "mcpserver-fsharp",
"defaultName": "McpServer",
"groupIdentity": "McpServer",
"sourceName": "McpServer-FSharp",
"preferNameDirectory": true,
"tags": {
"language": "F#",
"type": "project"
},
"guids": [
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeffffff"
],
"symbols": {
"hostIdentifier": {
"type": "bind",
"binding": "HostIdentifier"
},
"Transport": {
"type": "parameter",
"displayName": "The MCP server _transport type to use",
"description": "Whether to create a 'local' (stdio transport) or 'remote' (http transport) MCP server",
"datatype": "choice",
"choices": [
{
"choice": "local",
"description": "A console application will be created to use the stdio transport as a local MCP server"
},
{
"choice": "remote",
"description": "An ASP.NET Core web application will be created to use the http transport as a remote MCP server"
}
],
"defaultValue": "local"
},
"SelfContained": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"displayName": "Enable _self-contained publish",
"description": "Whether to enable the MCP server for publishing as a self-contained application."
},
"Framework": {
"type": "parameter",
"description": "The target framework for the project.",
"displayName": "Framework",
"datatype": "choice",
"choices": [
{
"choice": "net10.0",
"description": ".NET 10"
},
{
"choice": "net9.0",
"description": ".NET 9"
},
{
"choice": "net8.0",
"description": ".NET 8"
}
],
"replaces": "net10.0",
"defaultValue": "net10.0"
},
"httpsPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
},
"httpsPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 5000,
"high": 5300
}
},
"httpsPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "httpsPort",
"fallbackVariableName": "httpsPortGenerated"
},
"replaces": "9995",
"onlyIf": [{
"after": "localhost:"
}]
},
"httpPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTP endpoint in launchSettings.json."
},
"httpPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 6000,
"high": 6300
}
},
"httpPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "httpPort",
"fallbackVariableName": "httpPortGenerated"
},
"replaces": "9996",
"onlyIf": [{
"after": "localhost:"
}]
},
"IsTransportRemote": {
"type": "computed",
"value": "(Transport == \"remote\")"
},
"IsTransportLocal": {
"type": "computed",
"value": "(!IsTransportRemote)"
}
},
"primaryOutputs": [
{
"path": "./README.md"
},
{
"path": "./McpServer-FSharp.fsproj"
}
],
"sources": [
{
"source": "./common",
"target": "./"
},
{
"condition": "(IsTransportLocal)",
"source": "./local",
"target": "./"
},
{
"condition": "(IsTransportRemote)",
"source": "./remote",
"target": "./"
}
],
"postActions": [
{
"condition": "(hostIdentifier != \"dotnetcli\" && hostIdentifier != \"dotnetcli-preview\")",
"description": "Opens README file in the editor",
"manualInstructions": [],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "0"
},
"continueOnError": true
}
],
"SpecialCustomOperations": {
"**/*.md": {
"operations": [
{
"type": "conditional",
"configuration": {
"if": [ "#### ---#if" ],
"else": [ "#### ---#else" ],
"elseif": [ "#### ---#elseif", "#### ---#elif" ],
"endif": [ "#### ---#endif" ],
"trim": "true",
"wholeLine": "true",
"evaluator": "C++"
}
}
]
},
"**/*.http": {
"operations": [
{
"type": "conditional",
"configuration": {
"if": [ "#if" ],
"else": [ "#else" ],
"elseif": [ "#elseif", "#elif" ],
"endif": [ "#endif" ],
"trim": "true",
"wholeLine": "true",
"evaluator": "C++"
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace McpServer.Tools
open System
open System.ComponentModel
open System.Runtime.InteropServices
open ModelContextProtocol.Server

/// <summary>
/// Sample MCP tools for demonstration purposes.
/// These tools can be invoked by MCP clients to perform various operations.
/// </summary>
type RandomNumberTools() =

[<McpServerTool>]
[<Description("Generates a random number between the specified minimum and maximum values.")>]
member _.GetRandomNumber
(
[<Optional; DefaultParameterValue(0)>]
[<Description("Minimum value (inclusive)")>] min : int,
[<Optional; DefaultParameterValue(100)>]
[<Description("Maximum value (exclusive)")>] max : int
) =

Random.Shared.Next(min, max)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<!--#if (SelfContained)-->
<RuntimeIdentifiers>win-x64;win-arm64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64</RuntimeIdentifiers>
<!--#else-->
<RollForward>Major</RollForward>
<!--#endif -->
<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>
<!--#if (SelfContained)-->

<!-- 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>
<!--#endif -->

<!-- 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>
Comment thread
licon4812 marked this conversation as resolved.
</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>
<Compile Include="tools\RandomNumberTools.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="${PackageVersion:Microsoft.Extensions.Hosting}" />
<PackageReference Include="ModelContextProtocol" Version="${PackageVersion:ModelContextProtocol}" />
</ItemGroup>

</Project>
Loading