Skip to content

docs(hono): type the README route callback as Context - #3162

Open
ZainnQureshii wants to merge 1 commit into
modelcontextprotocol:mainfrom
ZainnQureshii:docs/hono-readme-context-type
Open

ZainnQureshii wants to merge 1 commit into
modelcontextprotocol:mainfrom
ZainnQureshii:docs/hono-readme-context-type

Conversation

@ZainnQureshii

Copy link
Copy Markdown

The Streamable HTTP example in packages/middleware/hono/README.md does not compile under strict TypeScript. This adds the Context annotation that docs/serving/hono.md already uses.

Motivation and Context

createMcpHonoApp() returns a plain Hono (packages/middleware/hono/src/hono.ts:83). With an inferred callback context, c.get's key parameter narrows to never, so the README's c.get('parsedBody') fails:

error TS2769: No overload matches this call.
  Overload 1 of 2, '(key: never): unknown', gave the following error.
    Argument of type '"parsedBody"' is not assignable to parameter of type 'never'.

docs/serving/hono.md:29 uses (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 import docs/serving/hono.md:17 and src/hono.ts:2 use.

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 in pnpm-lock.yaml), with createMcpHonoApp declared with its real Hono return 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

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

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>
@ZainnQureshii
ZainnQureshii requested a review from a team as a code owner November 8, 2026 17:17
@changeset-bot

changeset-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e6bb948

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3162

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3162

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3162

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3162

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3162

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3162

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3162

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3162

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3162

commit: e6bb948

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 9, 2026

This branch has not been deployed

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

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant