Repository navigation
docs(mcp-generator): custom tools, hooks, and context.fetch - #7940
Open
tdclarin854 wants to merge 2 commits into
Open
tdclarin854 wants to merge 2 commits into
tdclarin854 wants to merge 2 commits into
Conversation
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.
tdclarin854
requested review from
jkonrath-postman and
nerminamiller-postman
as code owners
November 19, 2026 21:54
|
|
||
| ### 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. |
Contributor
There was a problem hiding this comment.
🚫 [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. |
Contributor
There was a problem hiding this comment.
🚫 [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`. |
Contributor
There was a problem hiding this comment.
🚫 [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`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tomain.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
fern/products/mcp-generator/configure.mdx→/learn/mcp-generator/get-started/configurefern/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)fern sdk add-tool/fern sdk add-hook),@fern-api/mcp-toolingtypes, thedefinition+handlermodule shape (with example), the four hooks, andcontext.fetchsemantics (credentials only to thebaseUrlorigin, redirects not followed, 30s timeout; setcontent-typeon JSON bodies).tools/mergedToolsfilter.transformResultdoes not wrap custom-tool results (redact inside the handler instead), matching the generator's behavior.tag:filter bullet to note it also matches the OpenAPI-derived service name.SDK config reference (
/learn/sdks/reference/sdk-config-reference)generation.serverName/serverDescription/excludeAvailability/tools/toolsets/mergedTools/customTools/hooks, each linking to the Configure page.Verification
sdk-gen-coredevelop (see the FERN-263 gap'sfeature-reference.md/investigation.md). All features are live on prod.fern check: 0 errors; no new warnings.