go-sdk/.github/workflows/docs-check.yml
Maciej Kisiel a433a831d6
mcp: verify 'Origin' and 'Content-Type' headers (#842)
This PR introduces protection against cross-origin requests by
installing `http.CrossOriginProtection`.
By default, the zero value is used which does not contain any trusted
origins or bypass patterns.
The protection can be customized by providing a custom
`http.CrossOriginProtection` in `mcp.StreamableHTTPOptions`. Currently,
the deny handler set on the protection is ignored.
This default has an MCPGODEBUG option (`disableoriginverification`) to
disable the default protection.
It will be available until `v1.6.0` of the SDK.
We also increase the Go version required by the SDK to 1.25, since this
is the version that introduced `http.CrossOriginProtection`. This is in
line with the SDK's policy of supporting two newest Go versions (1.26
was released in February 2026).

Additionally, we start validating if the `Content-Type` header for
`POST` requests is set to `application/json` to avoid accepting
CORS-safelisted requests.
2026-03-13 11:36:41 +01:00

41 lines
1.2 KiB
YAML

name: Docs Check
on:
workflow_dispatch:
pull_request:
paths:
- 'internal/readme/**'
- 'README.md'
- 'internal/docs/**'
- 'docs/**'
permissions:
contents: read
jobs:
docs-check:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version: "^1.26"
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check docs are up-to-date
run: |
go generate ./...
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: docs are not up-to-date!"
echo ""
echo "The docs differ from what would be generated by go generate ./..."
echo "Please update internal/**/*.src.md instead of directly editing README.md or docs/ files,"
echo "then run go generate ./... to regenerate docs."
echo ""
echo "Changes:"
git status --porcelain
echo ""
echo "Diff:"
git diff
exit 1
fi
echo "Docs are up-to-date."