get_item_source

Full registry JSON for an item, including files[].content with the actual source. The heaviest tool by token cost — use it only after the agent has committed.

get_item_source returns the complete registry item, including the TSX source for every file. It's what the agent calls when it wants to read the code — to adapt it, splice pieces of it, or understand how a pattern is built.

When to use

  • The agent needs to read or modify the source rather than install it verbatim.
  • Comparing two components' implementations, not just their metadata.
  • Debugging "how does X work?" prompts where get_item metadata isn't enough.

If the agent just wants to install the component, skip this and go straight to get_install_command. The install URL pulls source directly from /r/* server-side — no need to route it through the agent.

How it works

Uses the same universal resolver as get_item (services/registry.ts#getRegistryItem). The only difference is that each files[i].content is kept intact.

The content that ships back has already been sanitized by the resolver:

  • JSDoc blocks at the top of the file are stripped (@title, @description, @premium, @related, @questions — those are metadata, not code).
  • Path aliases are normalized. @repo/shadcn-ui/components/ui/ and ~/components/ui/ both become @/components/ui/ so the file is paste-compatible with a standard shadcn setup.
  • For theme registry items, cssVars is built up from the theme's lightTheme / darkTheme objects rather than shipping raw TSX.
  • For icons, the SVG body is cleaned (fill/stroke/g-wrapper attributes stripped) and wrapped in a React component.

Source: lib/mcp/tools.ts#get_item_source + services/registry.ts.

Arguments

NameTypeRequiredNotes
namestringRegistry slug

Response

Same shape as get_item, with populated content on each file:

{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-announcement",
  "type": "registry:block",
  "title": "React Announcement Hero Block",
  "description": "A hero section with an announcement banner above the headline.",
  "author": "shadcn.io",
  "homepage": "https://www.shadcn.io/blocks/hero-announcement",
  "dependencies": ["lucide-react"],
  "registryDependencies": ["button", "badge"],
  "files": [
    {
      "path": "blocks/hero/hero-announcement.tsx",
      "type": "registry:block",
      "target": "components/blocks/hero/hero-announcement.tsx",
      "content": "\"use client\"\n\nimport { ArrowRight } from \"lucide-react\"\n...\n"
    }
  ]
}

Premium items are gated: if your Pro subscription is inactive, the tool handler itself doesn't run — the outer auth layer returns 403 before reaching the tool. For authenticated-but-non-Pro users, the /r/* endpoint redacts content; get_item_source via MCP never returns a redacted payload because the whole endpoint is Pro-gated.

Example prompts

use shadcnio and show me the source of hero-announcement so I can match its layout in a different component
use shadcnio to fetch the source of use-debounce — I want to see how it handles cleanup
use shadcnio to pull the source of pricing-grouped-comparison-table and tell me which parts would need changing to show 4 tiers instead of 3

Manual invocation

curl -s -X POST "https://www.shadcn.io/api/mcp?token=YOUR_TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "get_item_source",
      "arguments": { "name": "hero-announcement" }
    }
  }' | jq '.result.content[0].text | fromjson | .files[0].content' -r

The -r on the final jq emits the file content without JSON-quoting — pipe to a file or to bat for pretty-printing.

Tips + gotchas

  • Most expensive tool by token count. A typical block is 200–600 lines of TSX. Only call this after the agent has a specific target, not during browse.
  • Multi-file items — some components ship multiple files (files: [{...}, {...}]). Iterate the array; don't assume files[0].
  • Prefer get_install_command for installation. Having the agent pull source and paste it into your project is a token-hungry roundabout. The install command lets shadcn add pull source directly server-to-server.
  • JSDoc metadata is stripped@title, @description, @opening, @related, @questions appear in the top-level fields (title, description, etc.) but not in the returned source. If the agent needs JSDoc, use get_item to read the structured version.

Was this page helpful?

Sign in to leave feedback.