Introducing a new way to review your PRs.

Read the announcement

upstash / context7

Context7 Platform -- Up-to-date docs for AI agents

View on GitHub

13 documents · Updated Nov 16, 2026

docs / eve-docs-agent-example

Eve Docs Agent Example

Overview

examples/eve-docs-agent is a standalone eve example application named context7-docs-agent in examples/…/package.json. It defines a documentation Q&A agent that must search current official docs before answering library, framework, or API questions. The package is ESM ("type": "module"), uses Node 24.x, and exposes the usual eve lifecycle scripts: pnpm build runs eve build, pnpm dev runs eve dev, pnpm start runs eve start, and pnpm typecheck runs tsc.

The runtime entry point is examples/…/agent.ts, which exports defineAgent({ model: "anthropic/claude-sonnet-5" }). The model behavior is mainly constrained by examples/…/instructions.md: it identifies the assistant as a developer documentation assistant, requires calling search_docs before answering library/API usage questions, passes library and version when available, bases answers on returned snippets, cites source URLs, refuses to guess on irrelevant results, and keeps answers short.

The only custom tool is examples/…/search_docs.ts. It registers an eve defineTool with a Zod input schema containing query (required, non-empty), library (optional library name or Context7 ID), and version (optional release). During execution it calls getContext7().search(query, { libraries, version, type: "txt", signal }); libraries is set to a one-element array only when library is provided, and version is also forwarded only when a library was provided. The eve execution context's abort signal is passed through to the Context7 request, so cancelled agent runs can cancel documentation search.

examples/…/context7.ts owns Context7 client creation and caches the singleton in module state. When CONTEXT7_API_KEY is present, it constructs new Context7() and relies on the SDK's environment-based authentication. Otherwise it trims CONTEXT7_RESOURCE_ID; if that variable is empty it throws Set CONTEXT7_API_KEY or CONTEXT7_RESOURCE_ID for the connected Vercel resource. With a resource ID, it constructs new Context7({ authToken: () => getIntegrationToken(resourceId) }), using @vercel/integrations to mint Vercel Marketplace/OIDC-backed tokens for the connected Context7 resource.

The chat surface is examples/…/eve.ts, which exports eveChannel({ auth: [vercelOidc(), localDev(), placeholderAuth()] }). That means production deployments accept Vercel OIDC, local development is allowed through eve's local auth helper, and the example still includes placeholderAuth() as a template convenience rather than a real public auth policy.

Workspace and type checking are scoped to the example. examples/…/tsconfig.json uses target: ES2022, module/moduleResolution: NodeNext, strict: true, noEmit: true, Node types, and includes only agent/…/*.ts plus generated .eve/…/*.d.ts. examples/…/pnpm-workspace.yaml disables pnpm's global virtual store, excludes several fast-moving AI/Vercel/eve packages from minimum release age, allows esbuild postinstall builds, and overrides eve>undici to ^8.12.2. examples/…/pnpm-lock.yaml locks the example importer to @upstash/context7-sdk, @vercel/integrations, ai, eve, zod, @types/node, and TypeScript versions resolved for this package.

Deployment and local setup are documented in examples/…/README.md. The README's Vercel deploy button clones this example, connects the Context7 Marketplace integration, and asks for CONTEXT7_API_KEY; the alternative deployment path removes the API key and sets CONTEXT7_RESOURCE_ID so agent/…/context7.ts can call getIntegrationToken. Local development expects pnpm install, vercel link, vercel env pull, and pnpm dev; without Vercel, developers copy the env template to .env.local and provide Context7 and AI Gateway credentials. examples/eve-docs-agent/.gitignore ignores .env* but re-allows .env.example, plus generated/build directories including .eve, .vercel, .workflow-data, .next, .output, .nitro, and dist. examples/eve-docs-agent/.vercelignore keeps node_modules, eve output, Next/Nitro/output directories, and dist out of Vercel uploads.

Assistant-facing maintenance instructions are duplicated through examples/…/AGENTS.md and examples/…/CLAUDE.md (CLAUDE.md just references @AGENTS.md). AGENTS.md tells future coding agents to read eve guides from node_modules/eve/docs/, treat agent/…/search_docs.ts as the library-question tool, keep Context7 secrets out of commits, understand the API-key-versus-Vercel-resource auth split in agent/…/context7.ts, and replace placeholderAuth() in agent/…/eve.ts before exposing the agent outside the Vercel team.

Coupling

Risks

  • examples/…/eve.ts includes placeholderAuth() in the auth list. If this example is deployed as-is for users outside the owning Vercel team, the channel may not enforce the intended production access boundary; replace or remove it when turning the example into a real public assistant.
  • examples/…/context7.ts caches the first Context7 client it creates. If tests or a long-lived process mutate CONTEXT7_API_KEY or CONTEXT7_RESOURCE_ID after the first call to getContext7(), later searches will keep using the original auth mode until the module is reloaded.