Skip to content

Commit 4972040

Browse files
Merge branch 'main' into tommy/disallowed-tools-config
2 parents 82c4132 + 5e1c94b commit 4972040

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine AS ui-build
1+
FROM node:20-alpine@sha256:09e2b3d9726018aecf269bd35325f46bf75046a643a66d28360ec71132750ec8 AS ui-build
22
WORKDIR /app
33
COPY ui/package*.json ./ui/
44
RUN cd ui && npm ci
@@ -7,7 +7,7 @@ COPY ui/ ./ui/
77
RUN mkdir -p ./pkg/github/ui_dist && \
88
cd ui && npm run build
99

10-
FROM golang:1.25.7-alpine AS build
10+
FROM golang:1.25.7-alpine@sha256:f6751d823c26342f9506c03797d2527668d095b0a15f1862cddb4d927a7a4ced AS build
1111
ARG VERSION="dev"
1212

1313
# Set the working directory
@@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3030
-o /bin/github-mcp-server ./cmd/github-mcp-server
3131

3232
# Make a stage to run the app
33-
FROM gcr.io/distroless/base-debian12
33+
FROM gcr.io/distroless/base-debian12@sha256:937c7eaaf6f3f2d38a1f8c4aeff326f0c56e4593ea152e9e8f74d976dde52f56
3434

3535
# Add required MCP server annotation
3636
LABEL io.modelcontextprotocol.server.name="io.github.github/github-mcp-server"

pkg/github/server.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type MCPServerConfig struct {
7878

7979
type MCPServerOption func(*mcp.ServerOptions)
8080

81-
func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependencies, inv *inventory.Inventory) (*mcp.Server, error) {
81+
func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependencies, inv *inventory.Inventory, middleware ...mcp.Middleware) (*mcp.Server, error) {
8282
// Create the MCP server
8383
serverOpts := &mcp.ServerOptions{
8484
Instructions: inv.Instructions(),
@@ -103,9 +103,11 @@ func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependenci
103103

104104
ghServer := NewServer(cfg.Version, serverOpts)
105105

106-
// Add middlewares
107-
ghServer.AddReceivingMiddleware(addGitHubAPIErrorToContext)
106+
// Add middlewares. Order matters - for example, the error context middleware should be applied last so that it runs FIRST (closest to the handler) to ensure all errors are captured,
107+
// and any middleware that needs to read or modify the context should be before it.
108+
ghServer.AddReceivingMiddleware(middleware...)
108109
ghServer.AddReceivingMiddleware(InjectDepsMiddleware(deps))
110+
ghServer.AddReceivingMiddleware(addGitHubAPIErrorToContext)
109111

110112
if unrecognized := inv.UnrecognizedToolsets(); len(unrecognized) > 0 {
111113
cfg.Logger.Warn("Warning: unrecognized toolsets ignored", "toolsets", strings.Join(unrecognized, ", "))

pkg/http/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import (
1919
)
2020

2121
type InventoryFactoryFunc func(r *http.Request) (*inventory.Inventory, error)
22+
23+
// GitHubMCPServerFactoryFunc is a function type for creating a new MCP Server instance.
24+
// middleware are applied AFTER the default GitHub MCP Server middlewares (like error context injection)
2225
type GitHubMCPServerFactoryFunc func(r *http.Request, deps github.ToolDependencies, inventory *inventory.Inventory, cfg *github.MCPServerConfig) (*mcp.Server, error)
2326

2427
type Handler struct {

0 commit comments

Comments
 (0)