Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
shell: pwsh
run : |
cd ./__tests__
Invoke-Pester -Output Detailed
# Invoke-Pester -Output Detailed
7 changes: 3 additions & 4 deletions InstallModule.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
param ($fullPath)

if (-not $fullPath) {
$fullpath = $env:PSModulePath -split ":(?!\\)|;|," |
Where-Object {$_ -notlike ([System.Environment]::GetFolderPath("UserProfile")+"*") -and $_ -notlike "$pshome*"} |
Select-Object -First 1
$fullPath = Join-Path $fullPath -ChildPath "PSMCP"
$fullpath = $env:PSModulePath -split ":(?!\\)|;|," | Select-Object -First 1

$fullPath = Join-Path $fullPath -ChildPath "PSMCP"
}

Push-location $PSScriptRoot
Expand Down
2 changes: 1 addition & 1 deletion PSMCP.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RootModule = 'PSMCP.psm1'

# Version number of this module.
ModuleVersion = '0.1.0'
ModuleVersion = '0.1.2'

# ID used to uniquely identify this module
GUID = 'e1c26df8-e796-466f-a542-ec72988e9d90'
Expand Down
23 changes: 22 additions & 1 deletion Public/New-MCP.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Class TemplateNames : System.Management.Automation.IValidateSetValuesGenerator {
[String[]] GetValidValues() {
$templates = foreach ($template in Get-ChildItem $PSScriptRoot\..\template) {
$template.BaseName -replace '.template', ''
}

return $templates
}
}

function New-MCP {
[CmdletBinding(SupportsShouldProcess = $true)]
[OutputType([System.IO.DirectoryInfo])]
Expand All @@ -10,6 +20,9 @@ function New-MCP {
[string]
$ServerName = "MCPServer",

[ValidateSet([TemplateNames])]
[string]$template,

[Parameter()]
[switch]
$Force
Expand Down Expand Up @@ -57,7 +70,15 @@ function New-MCP {
$ModuleRoot = Split-Path -Path $ScriptDirectory -Parent

# Construct the template path
$TemplatePath = Join-Path -Path $ModuleRoot -ChildPath "template\server.template.ps1"

if (-not $template) {
$template = "server"
}

$templatePath = "template\$($template).template.ps1"

# $TemplatePath = Join-Path -Path $ModuleRoot -ChildPath "template\server.template.ps1"
$TemplatePath = Join-Path -Path $ModuleRoot -ChildPath $templatePath

if (-not (Test-Path -Path $TemplatePath -PathType Leaf)) {
throw "Server template file not found at '$TemplatePath'."
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ No more brittle glue code. No more hand-rolling APIs. Just describe what you wan
Welcome to the future of coding.
It’s not just execution—it’s collaboration.

## Using Templates

PSMCP allows you to start your MCP server project from predefined templates using the `-template` parameter with the `New-MCP` command. Templates provide a quick starting point with common configurations or specific functionalities.

To use a template, simply specify its name when creating your MCP project:

```powershell
# Example using the 'youtube' template
New-MCP -Path d:\\mygit\\MyYouTubeMCP -template youtube
```

This command will create a new MCP project in the specified path, using the `youtube.template.ps1` file as the basis for your `MCPServer.ps1`.

Available templates include:
- `server`: The default template, providing a basic server setup with an `Invoke-Addition` example function.
- `youtube`: A template pre-configured for interacting with YouTube (requires the `PSAI` module).

You can explore the available templates in the `template/` directory of the PSMCP module installation.

## Contributing to PSMCP

Contributions are welcomed from the community! Whether you're fixing bugs, adding features, improving documentation, or sharing examples, your help makes PSMCP better.
Expand Down
13 changes: 13 additions & 0 deletions __tests__/.vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"servers": {
"mcp-powershell-MCPServer": {
"type": "stdio",
"command": "pwsh",
"args": [
"-NoProfile",
"-Command",
"${workspaceFolder}\\MCPServer.ps1"
]
}
}
}
29 changes: 29 additions & 0 deletions __tests__/MCPServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#Requires -Module PSMCP

Set-LogFile "$PSScriptRoot\mcp_server.log"

<#
.SYNOPSIS
Adds two numbers together.

.DESCRIPTION
The Invoke-Addition function takes two numeric parameters and returns their sum.

.PARAMETER a
The first number to add.

.PARAMETER b
The second number to add.
#>
function Global:Invoke-Addition {
param(
[Parameter(Mandatory)]
[double]$a,
[Parameter(Mandatory)]
[double]$b
)

$a + $b
}

Start-McpServer Invoke-Addition
14 changes: 13 additions & 1 deletion __tests__/New-MCP.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Describe 'New-MCP' -Tag New-MCP -Skip {
AfterAll {
Remove-Item -Recurse -Force TestDrive:\
}

It "Should create the stuff on the testdrive" {
$testDrive = "TestDrive:"
$testPath = "$testDrive\DougFolder"
Expand Down Expand Up @@ -79,4 +79,16 @@ Start-McpServer Invoke-Addition
$fileLines[$i].Trim() | Should -Be $expectedLines[$i].Trim()
}
}

It "Should have these params and in order" {
$expectedParams = 'Path', 'ServerName', 'template', 'Force'

$actualParams = (Get-Command New-MCP).Parameters.Keys

$actualParams.Count | Should -Be $expectedParams.Count

for ($i = 0; $i -lt $expectedParams.Count; $i++) {
$actualParams[$i] | Should -Be $expectedParams[$i]
}
}
}
2 changes: 1 addition & 1 deletion __tests__/Register-MCPTool.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Describe "Register-MCPTool" -Skip {
Describe "Register-MCPTool" {
BeforeAll {
Import-Module $PSScriptRoot\..\PSMCP.psd1 -Force

Expand Down
5 changes: 5 additions & 0 deletions template/youtube.template.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Requires -Module PSMCP, PSAI

Set-LogFile "$PSScriptRoot\mcp_server.log"

Start-McpServer Search-YouTube, Get-YouTubeTranscript