@jadchene/mcp-gateway-service 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ [CmdletBinding(SupportsShouldProcess = $true)]
2
+ param(
3
+ [string]$ProjectRoot = (Split-Path -Parent $PSScriptRoot),
4
+ [string]$PublishRegistry = "https://registry.npmjs.org/",
5
+ [string]$RestoreRegistry = "",
6
+ [string]$Access = "public",
7
+ [string]$Otp = ""
8
+ )
9
+
10
+ $ErrorActionPreference = "Stop"
11
+ $userNpmrcPath = Join-Path $HOME ".npmrc"
12
+ $originalRegistry = ""
13
+
14
+ function Invoke-Step {
15
+ param(
16
+ [string]$FilePath,
17
+ [string[]]$Arguments,
18
+ [string]$Description
19
+ )
20
+
21
+ $argumentText = if ($Arguments.Count -gt 0) { $Arguments -join " " } else { "" }
22
+ $target = if ($argumentText) { "$FilePath $argumentText" } else { $FilePath }
23
+
24
+ if ($PSCmdlet.ShouldProcess($target, $Description)) {
25
+ & $FilePath @Arguments
26
+ if ($LASTEXITCODE -ne 0) {
27
+ throw "Command failed with exit code ${LASTEXITCODE}: $target"
28
+ }
29
+ }
30
+ }
31
+
32
+ function Test-NpmLogin {
33
+ param(
34
+ [string]$Registry
35
+ )
36
+
37
+ & npm whoami --registry $Registry *> $null
38
+ return $LASTEXITCODE -eq 0
39
+ }
40
+
41
+ function Show-UserNpmrcIfPresent {
42
+ if (-not (Test-Path $userNpmrcPath)) {
43
+ return
44
+ }
45
+
46
+ $item = Get-Item $userNpmrcPath -Force
47
+ if (($item.Attributes -band [System.IO.FileAttributes]::Hidden) -ne 0) {
48
+ $item.Attributes = $item.Attributes -bxor [System.IO.FileAttributes]::Hidden
49
+ }
50
+ }
51
+
52
+ function Hide-UserNpmrcIfPresent {
53
+ if (-not (Test-Path $userNpmrcPath)) {
54
+ return
55
+ }
56
+
57
+ $item = Get-Item $userNpmrcPath -Force
58
+ if (($item.Attributes -band [System.IO.FileAttributes]::Hidden) -eq 0) {
59
+ $item.Attributes = $item.Attributes -bor [System.IO.FileAttributes]::Hidden
60
+ }
61
+ }
62
+
63
+ $resolvedProjectRoot = (Resolve-Path $ProjectRoot).Path
64
+ $packageJsonPath = Join-Path $resolvedProjectRoot "package.json"
65
+
66
+ if (-not (Test-Path $packageJsonPath)) {
67
+ throw "package.json not found under project root: $resolvedProjectRoot"
68
+ }
69
+
70
+ Push-Location $resolvedProjectRoot
71
+ try {
72
+ Show-UserNpmrcIfPresent
73
+ $originalRegistry = (& npm config get registry).Trim()
74
+ if (-not $RestoreRegistry) {
75
+ $RestoreRegistry = $originalRegistry
76
+ }
77
+
78
+ Invoke-Step -FilePath "npm" -Arguments @("config", "set", "registry", $PublishRegistry) -Description "Switch npm registry to the publish registry"
79
+ Invoke-Step -FilePath "npm" -Arguments @("config", "get", "registry") -Description "Verify the npm publish registry"
80
+
81
+ if (-not (Test-NpmLogin -Registry $PublishRegistry)) {
82
+ Invoke-Step -FilePath "npm" -Arguments @("login", "--registry", $PublishRegistry) -Description "Log in to npm before publishing"
83
+ }
84
+
85
+ $publishArgs = @("publish", "--access", $Access)
86
+ if ($Otp) {
87
+ $publishArgs += "--otp=$Otp"
88
+ }
89
+
90
+ Invoke-Step -FilePath "npm" -Arguments $publishArgs -Description "Publish the package to npm"
91
+ }
92
+ finally {
93
+ try {
94
+ if ($RestoreRegistry) {
95
+ Invoke-Step -FilePath "npm" -Arguments @("config", "set", "registry", $RestoreRegistry) -Description "Restore the original npm registry"
96
+ Invoke-Step -FilePath "npm" -Arguments @("config", "get", "registry") -Description "Verify the restored npm registry"
97
+ }
98
+ }
99
+ finally {
100
+ Hide-UserNpmrcIfPresent
101
+ Pop-Location
102
+ }
103
+ }
104
+
105
+ Write-Host ""
106
+ Write-Host "npm publish flow completed."
107
+ Write-Host "Publish registry: $PublishRegistry"
108
+ Write-Host "Registry restored to: $RestoreRegistry"
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: mcp-gateway
3
+ description: Use the MCP gateway for token-efficient discovery of downstream MCP services, tool lists, tool schemas, and forwarded tool calls. Prefer this skill when the gateway exposes a fixed discovery surface instead of flattening all downstream tools.
4
+ ---
5
+
6
+ # MCP Gateway
7
+
8
+ Operate downstream MCP services through the gateway's fixed, token-efficient discovery interface.
9
+
10
+ ## Core Mandates
11
+
12
+ - **Discovery First**: Never guess a `serviceId` or downstream `toolName`. Discover them through the gateway.
13
+ - **Token Efficiency**: Do not enumerate every service and every tool unless the task genuinely needs it.
14
+ - **Schema Before First Call**: Before the first call to an unfamiliar downstream tool, fetch its schema.
15
+ - **Cache Mentally Per Session**: Reuse known service lists, tool lists, and schemas within the current session instead of asking again without reason.
16
+ - **Compression Recovery Gate**: After any context compression event, re-read `AGENTS.md` and this `SKILL.md` before continuing.
17
+
18
+ ## Required Workflow
19
+
20
+ 1. Call `gateway.listServices` once to find the right downstream service.
21
+ 2. Call `gateway.listTools(serviceId)` only for the selected service.
22
+ 3. Call `gateway.getToolSchema(serviceId, toolName)` only before the first use of that tool, or when arguments are unclear.
23
+ 4. Call `gateway.callTool(serviceId, toolName, arguments)` for execution.
24
+ 5. Re-discover only when a call fails, service availability changes, or the task clearly requires fresh metadata.
25
+
26
+ ## Response Shape Expectations
27
+
28
+ - `gateway.listServices` returns compact service entries with `serviceId`, `description`, and `available`.
29
+ - `gateway.listTools` returns compact tool entries with `name` and `description`.
30
+ - `gateway.getToolSchema` returns only `inputSchema` and `outputSchema`.
31
+ - `gateway.callTool` forwards the downstream MCP result directly with minimal or no gateway wrapping.
32
+
33
+ ## Token-Efficient Strategy
34
+
35
+ - Start with the smallest discovery call that can answer the current question.
36
+ - Avoid listing tools for multiple services when the target domain is already obvious.
37
+ - Avoid fetching schemas for multiple tools when only one likely matches the task.
38
+ - Do not repeatedly fetch schemas for the same tool within the same active session unless the tool appears to have changed.
39
+
40
+ ## Common Patterns
41
+
42
+ - Need a service for one task domain:
43
+ - `gateway.listServices`
44
+ - choose the most relevant `serviceId`
45
+ - `gateway.listTools({ serviceId: "selected-service" })`
46
+ - `gateway.getToolSchema({ serviceId: "selected-service", toolName: "selected-tool" })`
47
+ - `gateway.callTool({ serviceId: "selected-service", toolName: "selected-tool", arguments: {...} })`
48
+
49
+ - Need to inspect an unfamiliar tool before first use:
50
+ - `gateway.getToolSchema({ serviceId: "selected-service", toolName: "selected-tool" })`
51
+ - build arguments strictly from `inputSchema`
52
+ - call the tool only after the schema is understood
53
+
54
+ ## Prohibited Patterns
55
+
56
+ - **Never** flatten all downstream tools into your own notes unless the task explicitly needs a full inventory.
57
+ - **Never** invent arguments for a tool when the schema can be queried cheaply.
58
+ - **Never** assume a service is available without checking recent gateway discovery results when availability matters.
59
+
60
+ ## Practical Guidance
61
+
62
+ - Choose `serviceId` by task domain and service description instead of assuming a fixed service naming scheme.
63
+ - Prefer the smallest discovery step that can answer the question.
64
+ - If a downstream tool fails with a validation error, fetch or re-check its schema before retrying.