Skip to content

Conversation

@mattzcarey
Copy link
Contributor

  • loads from Github, caches chunks in KV for 1 day.
  • uses stemming to do a fuzzy keyword match.

@changeset-bot
Copy link

changeset-bot bot commented Nov 8, 2025

⚠️ No Changeset found

Latest commit: 502eb95

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
Copy link

pkg-pr-new bot commented Nov 8, 2025

Open in StackBlitz

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

commit: 502eb95

@claude
Copy link

claude bot commented Nov 8, 2025

Claude Code Review

Critical Issues

1. Missing KV namespace ID in wrangler.jsonc (site/agents/wrangler.jsonc:10-13)

  • The kv_namespaces binding lacks an id field required for production deployment
  • This will fail when deploying: wrangler deploy needs either id or preview_id
  • Add: "id": "your-kv-namespace-id" to the binding

2. Top-level await breaks ES module compatibility (site/agents/src/server/utils.ts:26-29)

  • const chunker = await RecursiveChunker.create(...) at module scope causes initialization issues
  • Workers with top-level await can have cold start problems and race conditions
  • Move chunker creation into fetchAndBuildIndex or lazy-initialize on first use

3. Environment access pattern is fragile (site/agents/src/server/utils.ts:3,40,126)

  • import { env } from "cloudflare:workers" followed by direct env.DOCS_KV access bypasses proper DI
  • This breaks testability and doesn't match Workers' execution model
  • The env should be passed as parameter from the fetch handler

Minor Issues

4. No test coverage

  • New MCP server functionality has no tests
  • Consider adding unit tests for search formatting and integration tests for the tool

5. Error messages lose context (site/agents/src/server/index.ts:58-67)

  • Generic "try again later" message doesn't help users debug issues
  • Consider surfacing error type (rate limit vs. cache miss vs. search failure)

6. Index rebuild on every request when cache miss (site/agents/src/server/utils.ts:139-171)

  • If KV cache expires, every request will rebuild the entire index from GitHub
  • No mutex/lock prevents concurrent expensive rebuilds
  • Consider using Durable Objects or a rebuild queue for cache warming

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

will review in detail later, this is exciting but I need to finish my slides haha

inputSchema
},
async ({ query, k }) => {
const searchEffect = Effect.gen(function* () {
Copy link
Contributor

Choose a reason for hiding this comment

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

sneaking in effect huh

"types": "wrangler types"
},
"dependencies": {
"@cfworker/json-schema": "^4.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

},
async ({ query, k }) => {
const searchEffect = Effect.gen(function* () {
console.log({ query, k });
Copy link
Contributor

Choose a reason for hiding this comment

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

stray log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'd kinda like to have some logging on the queries are being asked. We need to instrument the server properly but I added this till then.

export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
return createMcpHandler(mcpServer)(request, env, ctx);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can make a scheduled worker here and run this everyday

@threepointone
Copy link
Contributor

@mattzcarey can you check whether I've broken anything? if it looks good I'll land and ship

const CHUNK_SIZE = 2000;
const MIN_CHARS_PER_CHUNK = 500;

const chunker = await RecursiveChunker.create({
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I'm not sure this works in prod...

Copy link
Contributor

Choose a reason for hiding this comment

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

apparently it does

threepointone pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Nov 19, 2025
Adds documentation for the new Agents SDK Documentation MCP server that provides token-efficient search of Cloudflare Agents SDK documentation.

Related to cloudflare/agents#643

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@threepointone
Copy link
Contributor

📚 Documentation sync

A documentation PR has been created to sync these changes:

The documentation updates include:

  • Added Agents SDK Documentation MCP server to the catalog
  • Documented the search tool and usage patterns
  • Added information about caching and rate limiting

cc @cloudflare/docs-team

@threepointone
Copy link
Contributor

📚 Documentation sync status

✅ Documentation has been synced to cloudflare-docs#26617

This PR adds the Agents SDK Documentation MCP server to the catalog of Cloudflare-managed MCP servers.


This is an automated comment from the documentation sync workflow

@mattzcarey
Copy link
Contributor Author

Looks good!! :) can test it at https://agents-site.mattzcarey.workers.dev/mcp

@threepointone threepointone merged commit 4e285b2 into main Nov 19, 2025
5 checks passed
@threepointone threepointone deleted the feat-agents-mcp branch November 19, 2025 13:12
naji247 pushed a commit to MCPCat/agents that referenced this pull request Nov 20, 2025
* feat: agents mcp

* more effect and stemming

* add readme

* add note about ratelimiting

* move it all into the site app

* Update package-lock.json

* fix: add main entrypoint and node compat

---------

Co-authored-by: Sunil Pai <[email protected]>
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.

2 participants