Skip to content

docs(mcp-generator): custom tools, hooks, and context.fetch - #7940

Open
tdclarin854 wants to merge 2 commits into
devin/1794339126-mcp-generator-ga-code-updatesfrom
tdclarin854/mcp-docs-custom-tools-hooks
Open

tdclarin854 wants to merge 2 commits into
devin/1794339126-mcp-generator-ga-code-updatesfrom
tdclarin854/mcp-docs-custom-tools-hooks

Conversation

@tdclarin854

@tdclarin854 tdclarin854 commented Nov 19, 2026 •

Copy link
Copy Markdown

Stacked on top of #7812 (base = its branch devin/1794339126-mcp-generator-ga-code-updates). Merge this into #7812 when it looks good; #7812 then carries it to main.

Part of FERN-263 (docs catch-up for the net-new MCP features). Scope here: the custom tools / hooks gap on the Configure page + the missing MCP options in the sdk-config reference. Merged tools are already documented in #7812.

Pages changed

  • Configure the server — fern/products/mcp-generator/configure.mdx → /learn/mcp-generator/get-started/configure
  • SDK config reference — fern/products/sdks/reference/sdk-config-reference.mdx → /learn/sdks/reference/sdk-config-reference (the new "MCP target (language: mcp)" subsection)

What changed

Configure page (/learn/mcp-generator/get-started/configure)

  • New Add custom tools and hooks section: scaffold commands (fern sdk add-tool / fern sdk add-hook), @fern-api/mcp-tooling types, the definition+handler module shape (with example), the four hooks, and context.fetch semantics (credentials only to the baseUrl origin, redirects not followed, 30s timeout; set content-type on JSON bodies).
  • Custom tools stay in the default toolset even under a tools/mergedTools filter.
  • Accuracy: documents that transformResult does not wrap custom-tool results (redact inside the handler instead), matching the generator's behavior.
  • Corrected the tag: filter bullet to note it also matches the OpenAPI-derived service name.

SDK config reference (/learn/sdks/reference/sdk-config-reference)

  • New MCP target subsection documenting generation.serverName / serverDescription / excludeAvailability / tools / toolsets / mergedTools / customTools / hooks, each linking to the Configure page.

Verification

  • Cross-checked every claim against the shipped generator on sdk-gen-core develop (see the FERN-263 gap's feature-reference.md / investigation.md). All features are live on prod.
  • fern check: 0 errors; no new warnings.

Add a 'Custom tools and hooks' section to the Configure page covering the
scaffold commands (fern sdk add-tool/add-hook), the @fern-api/mcp-tooling
types, the definition+handler module shape, the four hooks, and context.fetch
semantics (origin-locked credentials, manual redirects, 30s timeout). Note
custom tools stay in the default toolset under a filter, and that
transformResult does not wrap custom-tool results. Correct the tag: filter to
note it also matches service names. Document the mcp target's generation
options in the sdk-config reference, linking to the Configure page.

### Call your API from a custom tool

`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] <Microsoft.Contractions> reported by reviewdog 🐶
Use 'doesn't' instead of 'does not'.

Suggested change
`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.
`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, doesn't follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.


### Call your API from a custom tool

`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] <Microsoft.Contractions> reported by reviewdog 🐶
Use 'can't' instead of 'cannot'.

Suggested change
`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.
`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials can't leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.


`context.fetch` is a drop-in replacement for the global `fetch` that routes the call through the server's request hooks and credential handling. It sends your API's credentials only to the configured `baseUrl` origin, does not follow redirects (a 3xx returns as-is, so credentials cannot leak to a redirect target), and times out after 30 seconds. Prefer it over the global `fetch`, which bypasses the hooks, the credentials, and the timeout.

`context.fetch` does not set a content type. On a `POST`, `PUT`, or `PATCH` with a JSON body, set `content-type: application/json`, or the body goes out as `text/plain` and many APIs answer `415`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] <Microsoft.Contractions> reported by reviewdog 🐶
Use 'doesn't' instead of 'does not'.

Suggested change
`context.fetch` does not set a content type. On a `POST`, `PUT`, or `PATCH` with a JSON body, set `content-type: application/json`, or the body goes out as `text/plain` and many APIs answer `415`.
`context.fetch` doesn't set a content type. On a `POST`, `PUT`, or `PATCH` with a JSON body, set `content-type: application/json`, or the body goes out as `text/plain` and many APIs answer `415`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant