Skip to content

Conversation

@HueCodes
Copy link

Add a Props type parameter to ExportedHandler so that ctx.props can be properly typed when using satisfies ExportedHandler<Env, Props>.

  • Add enhanced ExportedHandler<Env, Props, QueueHandlerMessage, CfHostMetadata>
  • Add Props-aware handler types (ExportedHandlerFetchHandler, etc.)
  • Export types from main entry point and agents/types
  • Add generic params to createMcpHandler and McpAgent.serve()

Fixes #501

Add a Props type parameter to ExportedHandler so that ctx.props can be
properly typed when using `satisfies ExportedHandler<Env, Props>`.

- Add enhanced ExportedHandler<Env, Props, QueueHandlerMessage, CfHostMetadata>
- Add Props-aware handler types (ExportedHandlerFetchHandler, etc.)
- Export types from main entry point and agents/types
- Add generic params to createMcpHandler and McpAgent.serve()

Fixes cloudflare#501
@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

🦋 Changeset detected

Latest commit: 4d75bb3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
agents Major
@cloudflare/ai-chat Major
@cloudflare/codemode Major
hono-agents Major

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@784

commit: 4d75bb3

Copy link
Contributor

@mattzcarey mattzcarey Jan 16, 2026

Choose a reason for hiding this comment

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

I'm not sure we should be typing these here. These are already defined in the output of wrangler types if I am not mistaken.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the quick reply! I want to make sure I understand the concern. Are you saying wrangler types already generates ExportedHandler with a Props parameter? I added Props support to enable typed ctx.props which I don't believe exists in the current wrangler types output. Should these types live elsewhere, or should I be extending the wrangler generated types differently?

}

export function createMcpHandler(
export function createMcpHandler<
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems like a good improvement independently of the types below.

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.

Make ExportedHandler support setting ExecutionContext<Props>

2 participants