modelcontextprotocol / modelcontextprotocol/typescript-sdk

`createMcpHonoApp` should support generics for Env (Bindings and Variables)

Open Beginner friendly
#1,877 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3 v2
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

NOTE: This issue is a feedback for v2 alpha.

https://github.com/modelcontextprotocol/typescript-sdk/blob/%40modelcontextprotocol/hono%402.0.0-alpha.2/packages/middleware/hono/src/hono.ts#L44

Currently, createMcpHonoApp returns a plain Hono instance with BlankEnv({}).

This makes it difficult to access typed environment variables (like c.env.DB in Cloudflare D1) within MCP handlers without resorting to unsafe type casting.

It would be great if we could pass Env types like:

const app = createMcpHonoApp<Env>();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/middleware/hono/src/hono.ts at the createMcpHonoApp definition linked in the issue, and inspect how its current plain Hono instance uses BlankEnv. Make the returned app accept an Env generic so bindings and variables such as c.env.DB remain typed when using createMcpHonoApp(); verify the resulting type behavior in the existing Hono middleware context.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.