[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FMEHSCK9KSWR79FV324ZBP":3,"skill-same:01M6FMEHSCK9KSWR79FV324ZBP":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":54,"commitSha":55,"skillDirectory":56,"forksCount":57,"repositoryHtmlUrl":58,"repositoryHomepageUrl":6,"ownerHtmlUrl":59,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":60,"install":61,"resources":74},"01M6FMEHSCK9KSWR79FV324ZBP","ydc-claude-agent-sdk-integration",null,"Integrate Claude Agent SDK with You.com HTTP MCP server for Python and TypeScript. Use when developer mentions Claude Agent SDK, Anthropic Agent SDK, or integrating Claude with MCP tools.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fedwardirby\u002Fydc-claude-agent-sdk-integration\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"ydc claude agent sdk integration","sdk","agent sdk","integration","claude agent sdk","node","you","with","with mcp","web-search","integrate","use","MCP","server","search","http","web","mcp server","python","typescript","2026-11-10 10:12:30",false,"---\nname: ydc-claude-agent-sdk-integration\ndescription: Integrate Claude Agent SDK with You.com HTTP MCP server for Python and TypeScript. Use when developer mentions Claude Agent SDK, Anthropic Agent SDK, or integrating Claude with MCP tools.\nlicense: MIT\ncompatibility: Python 3.10+ or TypeScript 5.2+ (for v2), Node.js 18+\nmetadata:\n  author: youdotcom-oss\n  category: sdk-integration\n  version: \"1.0.0\"\n  keywords: claude,anthropic,claude-agent-sdk,agent-sdk,mcp,you.com,integration,http-mcp,web-search,python,typescript\n---\n\n# Integrate Claude Agent SDK with You.com MCP\n\nInteractive workflow to set up Claude Agent SDK with You.com's HTTP MCP server.\n\n## Workflow\n\n1. **Ask: Language Choice**\n   * Python or TypeScript?\n\n2. **If TypeScript - Ask: SDK Version**\n   * v1 (stable, generator-based) or v2 (preview, send\u002Freceive pattern)?\n   * Note: v2 requires TypeScript 5.2+ for `await using` support\n\n3. **Install Package**\n   * Python: `pip install claude-agent-sdk`\n   * TypeScript: `npm install @anthropic-ai\u002Fclaude-agent-sdk`\n\n4. **Ask: Environment Variables**\n   * Using standard `YDC_API_KEY` and `ANTHROPIC_API_KEY`?\n   * Or custom names?\n   * Have they set them?\n   * If NO: Guide to get keys:\n     - YDC_API_KEY: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n     - ANTHROPIC_API_KEY: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n5. **Ask: File Location**\n   * NEW file: Ask where to create and what to name\n   * EXISTING file: Ask which file to integrate into (add HTTP MCP config)\n\n6. **Create\u002FUpdate File**\n\n   **For NEW files:**\n   * Use the complete template code from the \"Complete Templates\" section below\n   * User can run immediately with their API keys set\n\n   **For EXISTING files:**\n   * Add HTTP MCP server configuration to their existing code\n   * Python configuration block:\n     ```python\n     from claude_agent_sdk import query, ClaudeAgentOptions\n\n     options = ClaudeAgentOptions(\n         mcp_servers={\n             \"ydc\": {\n                 \"type\": \"http\",\n                 \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n                 \"headers\": {\n                     \"Authorization\": f\"Bearer {os.getenv('YDC_API_KEY')}\"\n                 }\n             }\n         },\n         allowed_tools=[\n             \"mcp__ydc__you_search\",\n             \"mcp__ydc__you_express\",\n             \"mcp__ydc__you_contents\"\n         ]\n     )\n     ```\n\n   * TypeScript configuration block:\n     ```typescript\n     const options = {\n       mcpServers: {\n         ydc: {\n           type: 'http' as const,\n           url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n           headers: {\n             Authorization: `Bearer ${process.env.YDC_API_KEY}`\n           }\n         }\n       },\n       allowedTools: [\n         'mcp__ydc__you_search',\n         'mcp__ydc__you_express',\n         'mcp__ydc__you_contents'\n       ]\n     };\n     ```\n\n## Complete Templates\n\nUse these complete templates for new files. Each template is ready to run with your API keys set.\n\n### Python Template (Complete Example)\n\n```python\n\"\"\"\nClaude Agent SDK with You.com HTTP MCP Server\nPython implementation with async\u002Fawait pattern\n\"\"\"\n\nimport os\nimport asyncio\nfrom claude_agent_sdk import query, ClaudeAgentOptions\n\n# Validate environment variables\nydc_api_key = os.getenv(\"YDC_API_KEY\")\nanthropic_api_key = os.getenv(\"ANTHROPIC_API_KEY\")\n\nif not ydc_api_key:\n    raise ValueError(\n        \"YDC_API_KEY environment variable is required. \"\n        \"Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\"\n    )\n\nif not anthropic_api_key:\n    raise ValueError(\n        \"ANTHROPIC_API_KEY environment variable is required. \"\n        \"Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\"\n    )\n\n\nasync def main():\n    \"\"\"\n    Example: Search for AI news and get results from You.com MCP server\n    \"\"\"\n    # Configure Claude Agent with HTTP MCP server\n    options = ClaudeAgentOptions(\n        mcp_servers={\n            \"ydc\": {\n                \"type\": \"http\",\n                \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n                \"headers\": {\"Authorization\": f\"Bearer {ydc_api_key}\"},\n            }\n        },\n        allowed_tools=[\n            \"mcp__ydc__you_search\",\n            \"mcp__ydc__you_express\",\n            \"mcp__ydc__you_contents\",\n        ],\n        model=\"claude-sonnet-4-5-20250929\",\n    )\n\n    # Query Claude with MCP tools available\n    async for message in query(\n        prompt=\"Search for the latest AI news from this week\",\n        options=options,\n    ):\n        # Handle different message types\n        if message.type == \"text\":\n            print(message.content)\n        elif message.type == \"tool_use\":\n            print(f\"\\n[Tool: {message.name}]\")\n            print(f\"Input: {message.input}\")\n        elif message.type == \"tool_result\":\n            print(f\"Result: {message.content}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### TypeScript v1 Template (Complete Example)\n\n```typescript\n\u002F**\n * Claude Agent SDK with You.com HTTP MCP Server\n * TypeScript v1 implementation with generator-based pattern\n *\u002F\n\nimport { query } from '@anthropic-ai\u002Fclaude-agent-sdk';\n\n\u002F\u002F Validate environment variables\nconst ydcApiKey = process.env.YDC_API_KEY;\nconst anthropicApiKey = process.env.ANTHROPIC_API_KEY;\n\nif (!ydcApiKey) {\n  throw new Error(\n    'YDC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys'\n  );\n}\n\nif (!anthropicApiKey) {\n  throw new Error(\n    'ANTHROPIC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys'\n  );\n}\n\n\u002F**\n * Example: Search for AI news and get results from You.com MCP server\n *\u002F\nasync function main() {\n  \u002F\u002F Query Claude with HTTP MCP configuration\n  const result = query({\n    prompt: 'Search for the latest AI news from this week',\n    options: {\n      mcpServers: {\n        ydc: {\n          type: 'http' as const,\n          url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n          headers: {\n            Authorization: `Bearer ${ydcApiKey}`,\n          },\n        },\n      },\n      allowedTools: [\n        'mcp__ydc__you_search',\n        'mcp__ydc__you_express',\n        'mcp__ydc__you_contents',\n      ],\n      model: 'claude-sonnet-4-5-20250929',\n    },\n  });\n\n  \u002F\u002F Process messages as they arrive\n  for await (const msg of result) {\n    if (msg.type === 'text') {\n      console.log(msg.content);\n    } else if (msg.type === 'tool_use') {\n      console.log(`\\n[Tool: ${msg.name}]`);\n      console.log(`Input: ${JSON.stringify(msg.input, null, 2)}`);\n    } else if (msg.type === 'tool_result') {\n      console.log(`Result: ${msg.content}`);\n    }\n  }\n}\n\nmain().catch(console.error);\n```\n\n### TypeScript v2 Template (Complete Example)\n\n```typescript\n\u002F**\n * Claude Agent SDK with You.com HTTP MCP Server\n * TypeScript v2 implementation with send\u002Freceive pattern\n * Requires TypeScript 5.2+ for 'await using' support\n *\u002F\n\nimport { unstable_v2_createSession } from '@anthropic-ai\u002Fclaude-agent-sdk';\n\n\u002F\u002F Validate environment variables\nconst ydcApiKey = process.env.YDC_API_KEY;\nconst anthropicApiKey = process.env.ANTHROPIC_API_KEY;\n\nif (!ydcApiKey) {\n  throw new Error(\n    'YDC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys'\n  );\n}\n\nif (!anthropicApiKey) {\n  throw new Error(\n    'ANTHROPIC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys'\n  );\n}\n\n\u002F**\n * Example: Search for AI news and get results from You.com MCP server\n *\u002F\nasync function main() {\n  \u002F\u002F Create session with HTTP MCP configuration\n  \u002F\u002F 'await using' ensures automatic cleanup when scope exits\n  await using session = unstable_v2_createSession({\n    mcpServers: {\n      ydc: {\n        type: 'http' as const,\n        url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n        headers: {\n          Authorization: `Bearer ${ydcApiKey}`,\n        },\n      },\n    },\n    allowedTools: [\n      'mcp__ydc__you_search',\n      'mcp__ydc__you_express',\n      'mcp__ydc__you_contents',\n    ],\n    model: 'claude-sonnet-4-5-20250929',\n  });\n\n  \u002F\u002F Send message to Claude\n  await session.send('Search for the latest AI news from this week');\n\n  \u002F\u002F Receive and process messages\n  for await (const msg of session.receive()) {\n    if (msg.type === 'text') {\n      console.log(msg.content);\n    } else if (msg.type === 'tool_use') {\n      console.log(`\\n[Tool: ${msg.name}]`);\n      console.log(`Input: ${JSON.stringify(msg.input, null, 2)}`);\n    } else if (msg.type === 'tool_result') {\n      console.log(`Result: ${msg.content}`);\n    }\n  }\n}\n\nmain().catch(console.error);\n```\n\n## HTTP MCP Server Configuration\n\nAll templates use You.com's **HTTP MCP server** for simplicity:\n\n**Python:**\n```python\nmcp_servers={\n    \"ydc\": {\n        \"type\": \"http\",\n        \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n        \"headers\": {\n            \"Authorization\": f\"Bearer {ydc_api_key}\"\n        }\n    }\n}\n```\n\n**TypeScript:**\n```typescript\nmcpServers: {\n  ydc: {\n    type: 'http' as const,\n    url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n    headers: {\n      Authorization: `Bearer ${ydcApiKey}`\n    }\n  }\n}\n```\n\n**Benefits of HTTP MCP:**\n- ✅ No local installation required\n- ✅ Stateless request\u002Fresponse model\n- ✅ Always up-to-date with latest version\n- ✅ Consistent across all environments\n- ✅ Production-ready and scalable\n- ✅ Works with existing HTTP infrastructure\n\n## Available You.com Tools\n\nAfter configuration, Claude can discover and use:\n- `mcp__ydc__you_search` - Web and news search\n- `mcp__ydc__you_express` - AI-powered answers with web context\n- `mcp__ydc__you_contents` - Web page content extraction\n\n## Environment Variables\n\nBoth API keys are required:\n\n```bash\n# Add to your .env file or shell profile\nexport YDC_API_KEY=\"your-you-api-key-here\"\nexport ANTHROPIC_API_KEY=\"your-anthropic-api-key-here\"\n```\n\n**Get your API keys:**\n- You.com: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n- Anthropic: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n## Validation Checklist\n\nBefore completing:\n\n- [ ] Package installed: `claude-agent-sdk` (Python) or `@anthropic-ai\u002Fclaude-agent-sdk` (TypeScript)\n- [ ] Environment variables set: `YDC_API_KEY` and `ANTHROPIC_API_KEY`\n- [ ] Template copied or configuration added to existing file\n- [ ] HTTP MCP server configured (`https:\u002F\u002Fapi.you.com\u002Fmcp`)\n- [ ] Authorization header includes `Bearer ${YDC_API_KEY}`\n- [ ] Allowed tools list includes You.com tools\n- [ ] File is executable (Python) or can be compiled (TypeScript)\n- [ ] Ready to test with example query\n\n## Testing Your Integration\n\n**Python:**\n```bash\npython your-file.py\n```\n\n**TypeScript:**\n```bash\n# With tsx (recommended for quick testing)\nnpx tsx your-file.ts\n\n# Or compile and run\ntsc your-file.ts && node your-file.js\n```\n\n## Common Issues\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>Cannot find module @anthropic-ai\u002Fclaude-agent-sdk\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nInstall the package:\n\n```bash\n# NPM\nnpm install @anthropic-ai\u002Fclaude-agent-sdk\n\n# Bun\nbun add @anthropic-ai\u002Fclaude-agent-sdk\n\n# Yarn\nyarn add @anthropic-ai\u002Fclaude-agent-sdk\n\n# pnpm\npnpm add @anthropic-ai\u002Fclaude-agent-sdk\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>YDC_API_KEY environment variable is required\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nSet your You.com API key:\n\n```bash\nexport YDC_API_KEY=\"your-api-key-here\"\n```\n\nGet your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>ANTHROPIC_API_KEY environment variable is required\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nSet your Anthropic API key:\n\n```bash\nexport ANTHROPIC_API_KEY=\"your-api-key-here\"\n```\n\nGet your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>MCP connection fails with 401 Unauthorized\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nVerify your YDC_API_KEY is valid:\n1. Check the key at https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n2. Ensure no extra spaces or quotes in the environment variable\n3. Verify the Authorization header format: `Bearer ${YDC_API_KEY}`\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>Tools not available or not being called\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nEnsure `allowedTools` includes the correct tool names:\n- `mcp__ydc__you_search` (not `you_search`)\n- `mcp__ydc__you_express` (not `you_express`)\n- `mcp__ydc__you_contents` (not `you_contents`)\n\nTool names must include the `mcp__ydc__` prefix.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>TypeScript error: Cannot use 'await using'\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nThe v2 SDK requires TypeScript 5.2+ for `await using` syntax.\n\n**Solution 1: Update TypeScript**\n```bash\nnpm install -D typescript@latest\n```\n\n**Solution 2: Use manual cleanup**\n```typescript\nconst session = unstable_v2_createSession({ \u002F* options *\u002F });\ntry {\n  await session.send('Your query');\n  for await (const msg of session.receive()) {\n    \u002F\u002F Process messages\n  }\n} finally {\n  session.close();\n}\n```\n\n**Solution 3: Use v1 SDK instead**\nChoose v1 during setup for broader TypeScript compatibility.\n\n\u003C\u002Fdetails>\n\n\n\n## Additional Resources\n\n* You.com MCP Server: https:\u002F\u002Fdocumentation.you.com\u002Fdeveloper-resources\u002Fmcp-server\n* Claude Agent SDK (Python): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpython\n* Claude Agent SDK (TypeScript v1): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Ftypescript\n* Claude Agent SDK (TypeScript v2): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Ftypescript-v2-preview\n* API Keys:\n  - You.com: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n  - Anthropic: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n","# Integrate Claude Agent SDK with You.com MCP\n\nInteractive workflow to set up Claude Agent SDK with You.com's HTTP MCP server.\n\n## Workflow\n\n1. **Ask: Language Choice**\n   * Python or TypeScript?\n\n2. **If TypeScript - Ask: SDK Version**\n   * v1 (stable, generator-based) or v2 (preview, send\u002Freceive pattern)?\n   * Note: v2 requires TypeScript 5.2+ for `await using` support\n\n3. **Install Package**\n   * Python: `pip install claude-agent-sdk`\n   * TypeScript: `npm install @anthropic-ai\u002Fclaude-agent-sdk`\n\n4. **Ask: Environment Variables**\n   * Using standard `YDC_API_KEY` and `ANTHROPIC_API_KEY`?\n   * Or custom names?\n   * Have they set them?\n   * If NO: Guide to get keys:\n     - YDC_API_KEY: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n     - ANTHROPIC_API_KEY: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n5. **Ask: File Location**\n   * NEW file: Ask where to create and what to name\n   * EXISTING file: Ask which file to integrate into (add HTTP MCP config)\n\n6. **Create\u002FUpdate File**\n\n   **For NEW files:**\n   * Use the complete template code from the \"Complete Templates\" section below\n   * User can run immediately with their API keys set\n\n   **For EXISTING files:**\n   * Add HTTP MCP server configuration to their existing code\n   * Python configuration block:\n     ```python\n     from claude_agent_sdk import query, ClaudeAgentOptions\n\n     options = ClaudeAgentOptions(\n         mcp_servers={\n             \"ydc\": {\n                 \"type\": \"http\",\n                 \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n                 \"headers\": {\n                     \"Authorization\": f\"Bearer {os.getenv('YDC_API_KEY')}\"\n                 }\n             }\n         },\n         allowed_tools=[\n             \"mcp__ydc__you_search\",\n             \"mcp__ydc__you_express\",\n             \"mcp__ydc__you_contents\"\n         ]\n     )\n     ```\n\n   * TypeScript configuration block:\n     ```typescript\n     const options = {\n       mcpServers: {\n         ydc: {\n           type: 'http' as const,\n           url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n           headers: {\n             Authorization: `Bearer ${process.env.YDC_API_KEY}`\n           }\n         }\n       },\n       allowedTools: [\n         'mcp__ydc__you_search',\n         'mcp__ydc__you_express',\n         'mcp__ydc__you_contents'\n       ]\n     };\n     ```\n\n## Complete Templates\n\nUse these complete templates for new files. Each template is ready to run with your API keys set.\n\n### Python Template (Complete Example)\n\n```python\n\"\"\"\nClaude Agent SDK with You.com HTTP MCP Server\nPython implementation with async\u002Fawait pattern\n\"\"\"\n\nimport os\nimport asyncio\nfrom claude_agent_sdk import query, ClaudeAgentOptions\n\n# Validate environment variables\nydc_api_key = os.getenv(\"YDC_API_KEY\")\nanthropic_api_key = os.getenv(\"ANTHROPIC_API_KEY\")\n\nif not ydc_api_key:\n    raise ValueError(\n        \"YDC_API_KEY environment variable is required. \"\n        \"Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\"\n    )\n\nif not anthropic_api_key:\n    raise ValueError(\n        \"ANTHROPIC_API_KEY environment variable is required. \"\n        \"Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\"\n    )\n\n\nasync def main():\n    \"\"\"\n    Example: Search for AI news and get results from You.com MCP server\n    \"\"\"\n    # Configure Claude Agent with HTTP MCP server\n    options = ClaudeAgentOptions(\n        mcp_servers={\n            \"ydc\": {\n                \"type\": \"http\",\n                \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n                \"headers\": {\"Authorization\": f\"Bearer {ydc_api_key}\"},\n            }\n        },\n        allowed_tools=[\n            \"mcp__ydc__you_search\",\n            \"mcp__ydc__you_express\",\n            \"mcp__ydc__you_contents\",\n        ],\n        model=\"claude-sonnet-4-5-20250929\",\n    )\n\n    # Query Claude with MCP tools available\n    async for message in query(\n        prompt=\"Search for the latest AI news from this week\",\n        options=options,\n    ):\n        # Handle different message types\n        if message.type == \"text\":\n            print(message.content)\n        elif message.type == \"tool_use\":\n            print(f\"\\n[Tool: {message.name}]\")\n            print(f\"Input: {message.input}\")\n        elif message.type == \"tool_result\":\n            print(f\"Result: {message.content}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### TypeScript v1 Template (Complete Example)\n\n```typescript\n\u002F**\n * Claude Agent SDK with You.com HTTP MCP Server\n * TypeScript v1 implementation with generator-based pattern\n *\u002F\n\nimport { query } from '@anthropic-ai\u002Fclaude-agent-sdk';\n\n\u002F\u002F Validate environment variables\nconst ydcApiKey = process.env.YDC_API_KEY;\nconst anthropicApiKey = process.env.ANTHROPIC_API_KEY;\n\nif (!ydcApiKey) {\n  throw new Error(\n    'YDC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys'\n  );\n}\n\nif (!anthropicApiKey) {\n  throw new Error(\n    'ANTHROPIC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys'\n  );\n}\n\n\u002F**\n * Example: Search for AI news and get results from You.com MCP server\n *\u002F\nasync function main() {\n  \u002F\u002F Query Claude with HTTP MCP configuration\n  const result = query({\n    prompt: 'Search for the latest AI news from this week',\n    options: {\n      mcpServers: {\n        ydc: {\n          type: 'http' as const,\n          url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n          headers: {\n            Authorization: `Bearer ${ydcApiKey}`,\n          },\n        },\n      },\n      allowedTools: [\n        'mcp__ydc__you_search',\n        'mcp__ydc__you_express',\n        'mcp__ydc__you_contents',\n      ],\n      model: 'claude-sonnet-4-5-20250929',\n    },\n  });\n\n  \u002F\u002F Process messages as they arrive\n  for await (const msg of result) {\n    if (msg.type === 'text') {\n      console.log(msg.content);\n    } else if (msg.type === 'tool_use') {\n      console.log(`\\n[Tool: ${msg.name}]`);\n      console.log(`Input: ${JSON.stringify(msg.input, null, 2)}`);\n    } else if (msg.type === 'tool_result') {\n      console.log(`Result: ${msg.content}`);\n    }\n  }\n}\n\nmain().catch(console.error);\n```\n\n### TypeScript v2 Template (Complete Example)\n\n```typescript\n\u002F**\n * Claude Agent SDK with You.com HTTP MCP Server\n * TypeScript v2 implementation with send\u002Freceive pattern\n * Requires TypeScript 5.2+ for 'await using' support\n *\u002F\n\nimport { unstable_v2_createSession } from '@anthropic-ai\u002Fclaude-agent-sdk';\n\n\u002F\u002F Validate environment variables\nconst ydcApiKey = process.env.YDC_API_KEY;\nconst anthropicApiKey = process.env.ANTHROPIC_API_KEY;\n\nif (!ydcApiKey) {\n  throw new Error(\n    'YDC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys'\n  );\n}\n\nif (!anthropicApiKey) {\n  throw new Error(\n    'ANTHROPIC_API_KEY environment variable is required. ' +\n      'Get your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys'\n  );\n}\n\n\u002F**\n * Example: Search for AI news and get results from You.com MCP server\n *\u002F\nasync function main() {\n  \u002F\u002F Create session with HTTP MCP configuration\n  \u002F\u002F 'await using' ensures automatic cleanup when scope exits\n  await using session = unstable_v2_createSession({\n    mcpServers: {\n      ydc: {\n        type: 'http' as const,\n        url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n        headers: {\n          Authorization: `Bearer ${ydcApiKey}`,\n        },\n      },\n    },\n    allowedTools: [\n      'mcp__ydc__you_search',\n      'mcp__ydc__you_express',\n      'mcp__ydc__you_contents',\n    ],\n    model: 'claude-sonnet-4-5-20250929',\n  });\n\n  \u002F\u002F Send message to Claude\n  await session.send('Search for the latest AI news from this week');\n\n  \u002F\u002F Receive and process messages\n  for await (const msg of session.receive()) {\n    if (msg.type === 'text') {\n      console.log(msg.content);\n    } else if (msg.type === 'tool_use') {\n      console.log(`\\n[Tool: ${msg.name}]`);\n      console.log(`Input: ${JSON.stringify(msg.input, null, 2)}`);\n    } else if (msg.type === 'tool_result') {\n      console.log(`Result: ${msg.content}`);\n    }\n  }\n}\n\nmain().catch(console.error);\n```\n\n## HTTP MCP Server Configuration\n\nAll templates use You.com's **HTTP MCP server** for simplicity:\n\n**Python:**\n```python\nmcp_servers={\n    \"ydc\": {\n        \"type\": \"http\",\n        \"url\": \"https:\u002F\u002Fapi.you.com\u002Fmcp\",\n        \"headers\": {\n            \"Authorization\": f\"Bearer {ydc_api_key}\"\n        }\n    }\n}\n```\n\n**TypeScript:**\n```typescript\nmcpServers: {\n  ydc: {\n    type: 'http' as const,\n    url: 'https:\u002F\u002Fapi.you.com\u002Fmcp',\n    headers: {\n      Authorization: `Bearer ${ydcApiKey}`\n    }\n  }\n}\n```\n\n**Benefits of HTTP MCP:**\n- ✅ No local installation required\n- ✅ Stateless request\u002Fresponse model\n- ✅ Always up-to-date with latest version\n- ✅ Consistent across all environments\n- ✅ Production-ready and scalable\n- ✅ Works with existing HTTP infrastructure\n\n## Available You.com Tools\n\nAfter configuration, Claude can discover and use:\n- `mcp__ydc__you_search` - Web and news search\n- `mcp__ydc__you_express` - AI-powered answers with web context\n- `mcp__ydc__you_contents` - Web page content extraction\n\n## Environment Variables\n\nBoth API keys are required:\n\n```bash\n# Add to your .env file or shell profile\nexport YDC_API_KEY=\"your-you-api-key-here\"\nexport ANTHROPIC_API_KEY=\"your-anthropic-api-key-here\"\n```\n\n**Get your API keys:**\n- You.com: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n- Anthropic: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n## Validation Checklist\n\nBefore completing:\n\n- [ ] Package installed: `claude-agent-sdk` (Python) or `@anthropic-ai\u002Fclaude-agent-sdk` (TypeScript)\n- [ ] Environment variables set: `YDC_API_KEY` and `ANTHROPIC_API_KEY`\n- [ ] Template copied or configuration added to existing file\n- [ ] HTTP MCP server configured (`https:\u002F\u002Fapi.you.com\u002Fmcp`)\n- [ ] Authorization header includes `Bearer ${YDC_API_KEY}`\n- [ ] Allowed tools list includes You.com tools\n- [ ] File is executable (Python) or can be compiled (TypeScript)\n- [ ] Ready to test with example query\n\n## Testing Your Integration\n\n**Python:**\n```bash\npython your-file.py\n```\n\n**TypeScript:**\n```bash\n# With tsx (recommended for quick testing)\nnpx tsx your-file.ts\n\n# Or compile and run\ntsc your-file.ts && node your-file.js\n```\n\n## Common Issues\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>Cannot find module @anthropic-ai\u002Fclaude-agent-sdk\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nInstall the package:\n\n```bash\n# NPM\nnpm install @anthropic-ai\u002Fclaude-agent-sdk\n\n# Bun\nbun add @anthropic-ai\u002Fclaude-agent-sdk\n\n# Yarn\nyarn add @anthropic-ai\u002Fclaude-agent-sdk\n\n# pnpm\npnpm add @anthropic-ai\u002Fclaude-agent-sdk\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>YDC_API_KEY environment variable is required\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nSet your You.com API key:\n\n```bash\nexport YDC_API_KEY=\"your-api-key-here\"\n```\n\nGet your key at: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>ANTHROPIC_API_KEY environment variable is required\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nSet your Anthropic API key:\n\n```bash\nexport ANTHROPIC_API_KEY=\"your-api-key-here\"\n```\n\nGet your key at: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>MCP connection fails with 401 Unauthorized\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nVerify your YDC_API_KEY is valid:\n1. Check the key at https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n2. Ensure no extra spaces or quotes in the environment variable\n3. Verify the Authorization header format: `Bearer ${YDC_API_KEY}`\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>Tools not available or not being called\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nEnsure `allowedTools` includes the correct tool names:\n- `mcp__ydc__you_search` (not `you_search`)\n- `mcp__ydc__you_express` (not `you_express`)\n- `mcp__ydc__you_contents` (not `you_contents`)\n\nTool names must include the `mcp__ydc__` prefix.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>TypeScript error: Cannot use 'await using'\u003C\u002Fstrong>\u003C\u002Fsummary>\n\nThe v2 SDK requires TypeScript 5.2+ for `await using` syntax.\n\n**Solution 1: Update TypeScript**\n```bash\nnpm install -D typescript@latest\n```\n\n**Solution 2: Use manual cleanup**\n```typescript\nconst session = unstable_v2_createSession({ \u002F* options *\u002F });\ntry {\n  await session.send('Your query');\n  for await (const msg of session.receive()) {\n    \u002F\u002F Process messages\n  }\n} finally {\n  session.close();\n}\n```\n\n**Solution 3: Use v1 SDK instead**\nChoose v1 during setup for broader TypeScript compatibility.\n\n\u003C\u002Fdetails>\n\n\n\n## Additional Resources\n\n* You.com MCP Server: https:\u002F\u002Fdocumentation.you.com\u002Fdeveloper-resources\u002Fmcp-server\n* Claude Agent SDK (Python): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpython\n* Claude Agent SDK (TypeScript v1): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Ftypescript\n* Claude Agent SDK (TypeScript v2): https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Ftypescript-v2-preview\n* API Keys:\n  - You.com: https:\u002F\u002Fyou.com\u002Fplatform\u002Fapi-keys\n  - Anthropic: https:\u002F\u002Fconsole.anthropic.com\u002Fsettings\u002Fkeys\n",{"name":5,"license":14,"metadata":48,"description":7,"compatibility":53},{"author":49,"version":50,"category":51,"keywords":52},"youdotcom-oss","1.0.0","sdk-integration","claude,anthropic,claude-agent-sdk,agent-sdk,mcp,you.com,integration,http-mcp,web-search,python,typescript","Python 3.10+ or TypeScript 5.2+ (for v2), Node.js 18+","main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Fedwardirby\u002Fydc-claude-agent-sdk-integration",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add kbarbel640-del\u002Fskills --skill ydc-claude-agent-sdk-integration",{"tool":67,"command":68},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill ydc-claude-agent-sdk-integration",{"tool":70,"command":71},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill ydc-claude-agent-sdk-integration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fedwardirby\u002Fydc-claude-agent-sdk-integration\u002FSKILL.md",true,[75],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"_meta.json","REFERENCE","参考文档",338,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fedwardirby\u002Fydc-claude-agent-sdk-integration\u002F_meta.json",[82,112,136,156,162,182],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":93,"publishedAt":43},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[88],{"categoryNo":89,"categoryName":90,"taxonomyType":91,"taxonomyTypeDesc":92},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[94,95,96,30,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111],"crowd prompting","prompting","api","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":119,"publishedAt":43},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[118],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[120,96,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,100,34],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":145,"publishedAt":43},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[142],{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000021","资料检索与研究",[146,147,148,149,150,151,152,30,153,134,34,154,96,38,155],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","via",{"skillNo":157,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":161,"publishedAt":43},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[160],{"categoryNo":143,"categoryName":144,"taxonomyType":20,"taxonomyTypeDesc":21},[149,148,147,146,155,151,152,30,150,134,34,153,154,96,38],{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":43},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[169,170,171,172,173,174,175,176,177,178,179,180,181],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":192,"publishedAt":43},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[188,189],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":190,"categoryName":191,"taxonomyType":91,"taxonomyTypeDesc":92},"01JBSEEDCAT000000000000037","律师与法务",[193,194,195,196,30,197,198,54,199,154,200,201,202,203,204,109,205,206,207],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]