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
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ New-MCP d:\temp\testMCP
code-insiders d:\temp\testMCP
```

## Install VS Code Insiders
## Install VS Code

To use PSMCP effectively, you'll need VS Code Insiders. Here's how to install it:
To use PSMCP effectively, you'll need VS Code v1.99.3 or later. Here's how to install it:

1. Visit the [VS Code Insiders download page](https://code.visualstudio.com/insiders/)
1. Visit the [VS Code download page](https://code.visualstudio.com/)
2. Download the appropriate version for your operating system
3. Run the installer and follow the on-screen instructions


## Set up GitHub Copilot in VS Code

This guide walks you through setting up GitHub Copilot in Visual Studio Code. To use Copilot in VS Code, you need to have access to GitHub Copilot with your GitHub account.

[GitHub Copilot Setup Guide](https://code.visualstudio.com/docs/copilot/setup)


## Getting Started with PSMCP

### New MCP
Expand All @@ -59,7 +58,6 @@ Start by creating a new MCP server with a simple command. This scaffolds the nec

Once initialized, you're ready to configure your MCP tools—no YAML, no fuss.


### MCP JSON

The JSON file defines your available tools. In this example, we’re creating a simple Invoke-Addition function.
Expand All @@ -69,8 +67,8 @@ The JSON file defines your available tools. In this example, we’re creating a
Clicking "Start" embeds the tool definition into the MCP config. Now it’s registered and ready to go.

## After Clicking Start
With the tool registered, starting the server wires up everything under the hood.

With the tool registered, starting the server wires up everything under the hood.

![alt text](media/03-Running.png)

Expand All @@ -93,19 +91,33 @@ Copilot steps in, proposing to call your registered function based on your promp
Confirm to execute and let the AI orchestrate the rest.

## Expand the Run

Peek under the hood—see the actual arguments passed to your function.

![alt text](media/06-ExpandRun.png)

Confirm to execute and let the AI orchestrate the rest.

### After Run

Execution complete. The function ran with your inputs, and now you get the result.

![alt text](media/07-AfterRun.png)

This isn’t just code—it’s a conversation. One prompt, one response, and a world of automation opens up.

## Creating your own Functions

Edit the <yourMCPServerName.ps1> file adding your functions.

*TIPS:*

- Write Help/Comments for your functions that describes what the function does, example(s) and outputs. This will help your MCP Client discover the capabilities and use the functions how you intended.
- Make your Functions Global. (e.g. functionName Global:Get-myFunction {})
- At the bottom of your <yourMCPServerName.ps1> add each function comma seperated so that they will be availabile in your MCP Client (e.g. VSCode)

![alt text](media/08-CreatingYourOwnFunctions.png)

🟨 Conclusion
This workflow redefines how we build and run tools. From scaffolding an MCP server to interacting with it using plain language, the line between prompt and program is disappearing.

Expand Down
88 changes: 88 additions & 0 deletions examples/LocationMCPServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#Requires -Module PSMCP

Set-LogFile "$PSScriptRoot\mcp_server.log"

<#
.SYNOPSIS
Get my public IP Address

.DESCRIPTION
Uses http://ipinfo.io/json to get the public IP Address of the machine running this script.
This is useful for testing and debugging purposes, especially when working with APIs that require a public IP Address.

.EXAMPLE
Get-PublicIPAddress

.OUTPUTS
Returns the public IP Address of the machine running the script.
#>

function Global:Get-PublicIPAddress {
[CmdletBinding()]
Param
()
Begin {
Write-Verbose -Message "Getting public IP Address"
}
Process {
try {
$ip = Invoke-RestMethod http://ipinfo.io/json | Select-Object -exp ip
Write-Output $ip
}
catch {
Write-Warning -Message "Unable to get public IP Address: $_"
}
}
End {
}
}


<#
.Synopsis
Can resolve either an IP Address or a Domain Name and give you geolocation information.
.DESCRIPTION
This module is using https://freegeoip.live API which is free. Yes. It's totally free. They believe that digital businesses need to get such kind of service for free. Many services are selling Geoip API as a service, but they think that it should be totally free. Feel free to their API as much as you want without any limit other than 10,000 queries per hour for one IP address. I thought this would be another good addition to add to the Powershell Gallery.
.Parameter IP
This parameter is used to specify the IP Address you want to find the geolocation information
.Parameter DomainName
This parameter is used to specify the Domain Name address you want to find the geolocation information
.EXAMPLE
Find-Geolocation -DomainName portsmouth.co.uk
.EXAMPLE
Find-Geolocation -IP 141.193.213.10
#>
function Global:Find-Geolocation {
[CmdletBinding()]
Param
(
[Parameter(ParameterSetName = 'IP Address Parameter Set')]
[ipaddress]$IP,
[Parameter(ParameterSetName = 'Domain Name Parameter Set')]
[System.Uri]$DomainName
)

Begin {
if ($IP) {
$Pattern = $IP
}
if ($DomainName) {
$Pattern = $DomainName
}
}
Process {
foreach ($item in $Pattern) {
Write-Verbose -Message "About to find out more information on $item"
try {
Invoke-RestMethod -Method Get -Uri https://freegeoip.live/json/$item -ErrorAction Stop
}
catch {
Write-Warning -Message "$item : $_"
}
}
}
End {
}
}

Start-McpServer Find-Geolocation, Get-PublicIPAddress
Binary file added media/08-CreatingYourOwnFunctions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.