Repository navigation
docs(hono): type the README route callback as Context - #3162
Open
ZainnQureshii wants to merge 1 commit into
Open
ZainnQureshii wants to merge 1 commit into
ZainnQureshii wants to merge 1 commit into
Conversation
createMcpHonoApp() returns a plain Hono, so on an inferred callback context c.get('parsedBody') fails with TS2769. docs/serving/hono.md already uses the explicit c: Context annotation for this reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This branch has not been deployed
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.
The Streamable HTTP example in
packages/middleware/hono/README.mddoes not compile under strict TypeScript. This adds theContextannotation thatdocs/serving/hono.mdalready uses.Motivation and Context
createMcpHonoApp()returns a plainHono(packages/middleware/hono/src/hono.ts:83). With an inferred callback context,c.get's key parameter narrows tonever, so the README'sc.get('parsedBody')fails:docs/serving/hono.md:29uses(c: Context) =>and its tip at line 37 explains the same failure. The README example now matches:import { createMcpHonoApp } from '@modelcontextprotocol/hono'; +import type { Context } from 'hono'; const app = createMcpHonoApp(); -app.all('/mcp', async c => { +app.all('/mcp', async (c: Context) => {import type { Context } from 'hono'is the same importdocs/serving/hono.md:17andsrc/hono.ts:2use.How Has This Been Tested?
The example's route callback was compiled before and after with
tsc --noEmit --strict(TypeScript 5.9.3, Hono 4.12.9 as pinned inpnpm-lock.yaml), withcreateMcpHonoAppdeclared with its realHonoreturn type and the transport stubbed: TS2769 before (exit 2), clean after (exit 0). That was a focused type check, not a full app build.Breaking Changes
None.
Types of changes
Checklist
Additional context
README-only, so no changeset, as with the package README change in #2955. This PR was prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code