[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69B6XKPVJYTPSCF7GZDCT2R":3,"skill-same:01M69B6XKPVJYTPSCF7GZDCT2R":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":45,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M69B6XKPVJYTPSCF7GZDCT2R","mcp-builder",null,"Build MCP (Model Context Protocol) clients to connect AI agents with external tools and data sources. Use when building integrations with MCP servers.","microsoft\u002Fcopilot-sdk-samples","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69B6KG9ME0SH4E5WPS0H0D1",26,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fcopilot-sdk-samples\u002Fblob\u002Fmain\u002Fsamples\u002Fskill-testing\u002Fsdk\u002Fskills\u002Fmcp-builder\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30],"MCP","mcp builder","typescript","ai agents","sdk","model context protocol","copilot","2026-11-10 10:12:30",false,"---\nname: mcp-builder\ndescription: Build MCP (Model Context Protocol) clients to connect AI agents with external tools and data sources. Use when building integrations with MCP servers.\nlicense: MIT\ncompatibility: Requires TypeScript, Node.js 18+\nmetadata:\n  author: copilot-sdk-samples\n  version: \"1.0\"\n---\n\n# MCP Builder Skill\n\nBuild MCP (Model Context Protocol) clients that connect AI agents with external tools and data sources.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Building a client to connect to an MCP server\n- Integrating AI agents with external data sources via MCP\n- Creating typed wrappers around MCP tool calls\n- The user mentions \"MCP\", \"Model Context Protocol\", or needs to connect to an MCP endpoint\n\n## MCP Protocol Overview\n\nMCP is an open protocol for connecting AI models to external tools and data. Key concepts:\n\n1. **MCP Server**: Exposes tools, resources, and prompts via JSON-RPC over HTTP (streamable) or stdio\n2. **MCP Client**: Connects to servers, discovers tools, and executes tool calls\n3. **Tools**: Functions the model can invoke (e.g., `search_docs`, `fetch_page`)\n4. **Resources**: Data the model can read (e.g., `docs:\u002F\u002Fazure\u002Foverview`)\n\n## Implementation Pattern\n\nFollow this pattern when building MCP clients:\n\n### 1. Define the Interface\n\n```typescript\nexport interface MCPClientConfig {\n  mode: \"mock\" | \"live\";\n  endpoint?: string;\n}\n\nexport interface MyMCPClient {\n  readonly mode: \"mock\" | \"live\";\n  readonly isInitialized: boolean;\n\n  initialize(): Promise\u003CConnectorResult\u003Cvoid>>;\n  dispose(): Promise\u003Cvoid>;\n\n  \u002F\u002F Add tool-specific methods based on server capabilities\n  toolName(args: ToolArgs): Promise\u003CConnectorResult\u003CToolResult>>;\n}\n```\n\n### 2. Implement Mock Client First\n\nAlways create a mock implementation that works without network calls:\n\n```typescript\nclass MockMyMCPClient implements MyMCPClient {\n  readonly mode = \"mock\" as const;\n  private _isInitialized = false;\n\n  get isInitialized(): boolean {\n    return this._isInitialized;\n  }\n\n  async initialize(): Promise\u003CConnectorResult\u003Cvoid>> {\n    this._isInitialized = true;\n    return success(undefined);\n  }\n\n  async dispose(): Promise\u003Cvoid> {\n    this._isInitialized = false;\n  }\n\n  async toolName(args: ToolArgs): Promise\u003CConnectorResult\u003CToolResult>> {\n    if (!this._isInitialized) {\n      return failure({\n        code: ErrorCodes.NOT_INITIALIZED,\n        message: \"Client not initialized\",\n      });\n    }\n    \u002F\u002F Return realistic mock data\n    return success({\n      \u002F* mock result *\u002F\n    });\n  }\n}\n```\n\n### 3. Use ConnectorResult Pattern\n\nAll methods must return `ConnectorResult\u003CT>`:\n\n```typescript\nimport {\n  ConnectorResult,\n  success,\n  failure,\n  ErrorCodes,\n} from \"..\u002Fshared\u002Fconnectors\u002Ftypes.js\";\n\n\u002F\u002F Success\nreturn success(data);\n\n\u002F\u002F Failure\nreturn failure({\n  code: ErrorCodes.NOT_FOUND,\n  message: \"Resource not found\",\n});\n```\n\n### 4. Factory Function\n\nExport a factory function:\n\n```typescript\nexport function createMyMCPClient(config: MCPClientConfig): MyMCPClient {\n  if (config.mode === \"mock\") {\n    return new MockMyMCPClient(config);\n  }\n  return new LiveMyMCPClient(config);\n}\n```\n\n## Example: Microsoft Learn MCP Server\n\nThe Microsoft Learn MCP Server (`https:\u002F\u002Flearn.microsoft.com\u002Fapi\u002Fmcp`) provides:\n\n### Tools\n\n1. `microsoft_docs_search` - Search Microsoft Learn documentation\n2. `microsoft_docs_fetch` - Fetch and convert a page to markdown\n3. `microsoft_code_sample_search` - Search code samples\n\n### Client Implementation\n\n```typescript\nexport interface DocSearchResult {\n  title: string;\n  url: string;\n  snippet: string;\n}\n\nexport interface MSLearnMCPClient {\n  readonly mode: \"mock\" | \"live\";\n  readonly isInitialized: boolean;\n\n  initialize(): Promise\u003CConnectorResult\u003Cvoid>>;\n  dispose(): Promise\u003Cvoid>;\n\n  searchDocs(query: string): Promise\u003CConnectorResult\u003CDocSearchResult[]>>;\n  fetchDoc(url: string): Promise\u003CConnectorResult\u003Cstring>>;\n  searchCodeSamples(\n    query: string,\n    language?: string,\n  ): Promise\u003CConnectorResult\u003CCodeSampleResult[]>>;\n}\n```\n\n## Testing Requirements\n\nEvery MCP client must include:\n\n1. Unit tests using Vitest\n2. Tests for initialization\u002Fdisposal\n3. Tests for each tool method\n4. Tests for error handling (NOT_INITIALIZED, etc.)\n\n```typescript\ndescribe(\"MyMCPClient\", () => {\n  let client: MyMCPClient;\n\n  beforeEach(async () => {\n    client = createMyMCPClient({ mode: \"mock\" });\n    await client.initialize();\n  });\n\n  afterEach(async () => {\n    await client.dispose();\n  });\n\n  it(\"should initialize successfully\", () => {\n    expect(client.isInitialized).toBe(true);\n  });\n\n  it(\"should fail when not initialized\", async () => {\n    const uninit = createMyMCPClient({ mode: \"mock\" });\n    const result = await uninit.toolName({});\n    expect(result.success).toBe(false);\n    expect(result.error?.code).toBe(\"NOT_INITIALIZED\");\n  });\n});\n```\n\n## File Structure\n\n```\nshared\u002Fconnectors\u002F\u003Cname>\u002F\n├── client.ts    # Client implementation\n└── index.ts     # Public exports\n\ntest\u002Fconnectors\u002F\n└── \u003Cname>.test.ts\n```\n\n## Acceptance Criteria\n\nA valid MCP client implementation must:\n\n1. ✅ Export a factory function `create\u003CName>Client(config)`\n2. ✅ Support both `mock` and `live` modes\n3. ✅ Use `ConnectorResult\u003CT>` for all async operations\n4. ✅ Have `isInitialized` property\n5. ✅ Return `NOT_INITIALIZED` error when called before `initialize()`\n6. ✅ Include comprehensive unit tests\n7. ✅ Follow existing connector patterns in the codebase\n","# MCP Builder Skill\n\nBuild MCP (Model Context Protocol) clients that connect AI agents with external tools and data sources.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Building a client to connect to an MCP server\n- Integrating AI agents with external data sources via MCP\n- Creating typed wrappers around MCP tool calls\n- The user mentions \"MCP\", \"Model Context Protocol\", or needs to connect to an MCP endpoint\n\n## MCP Protocol Overview\n\nMCP is an open protocol for connecting AI models to external tools and data. Key concepts:\n\n1. **MCP Server**: Exposes tools, resources, and prompts via JSON-RPC over HTTP (streamable) or stdio\n2. **MCP Client**: Connects to servers, discovers tools, and executes tool calls\n3. **Tools**: Functions the model can invoke (e.g., `search_docs`, `fetch_page`)\n4. **Resources**: Data the model can read (e.g., `docs:\u002F\u002Fazure\u002Foverview`)\n\n## Implementation Pattern\n\nFollow this pattern when building MCP clients:\n\n### 1. Define the Interface\n\n```typescript\nexport interface MCPClientConfig {\n  mode: \"mock\" | \"live\";\n  endpoint?: string;\n}\n\nexport interface MyMCPClient {\n  readonly mode: \"mock\" | \"live\";\n  readonly isInitialized: boolean;\n\n  initialize(): Promise\u003CConnectorResult\u003Cvoid>>;\n  dispose(): Promise\u003Cvoid>;\n\n  \u002F\u002F Add tool-specific methods based on server capabilities\n  toolName(args: ToolArgs): Promise\u003CConnectorResult\u003CToolResult>>;\n}\n```\n\n### 2. Implement Mock Client First\n\nAlways create a mock implementation that works without network calls:\n\n```typescript\nclass MockMyMCPClient implements MyMCPClient {\n  readonly mode = \"mock\" as const;\n  private _isInitialized = false;\n\n  get isInitialized(): boolean {\n    return this._isInitialized;\n  }\n\n  async initialize(): Promise\u003CConnectorResult\u003Cvoid>> {\n    this._isInitialized = true;\n    return success(undefined);\n  }\n\n  async dispose(): Promise\u003Cvoid> {\n    this._isInitialized = false;\n  }\n\n  async toolName(args: ToolArgs): Promise\u003CConnectorResult\u003CToolResult>> {\n    if (!this._isInitialized) {\n      return failure({\n        code: ErrorCodes.NOT_INITIALIZED,\n        message: \"Client not initialized\",\n      });\n    }\n    \u002F\u002F Return realistic mock data\n    return success({\n      \u002F* mock result *\u002F\n    });\n  }\n}\n```\n\n### 3. Use ConnectorResult Pattern\n\nAll methods must return `ConnectorResult\u003CT>`:\n\n```typescript\nimport {\n  ConnectorResult,\n  success,\n  failure,\n  ErrorCodes,\n} from \"..\u002Fshared\u002Fconnectors\u002Ftypes.js\";\n\n\u002F\u002F Success\nreturn success(data);\n\n\u002F\u002F Failure\nreturn failure({\n  code: ErrorCodes.NOT_FOUND,\n  message: \"Resource not found\",\n});\n```\n\n### 4. Factory Function\n\nExport a factory function:\n\n```typescript\nexport function createMyMCPClient(config: MCPClientConfig): MyMCPClient {\n  if (config.mode === \"mock\") {\n    return new MockMyMCPClient(config);\n  }\n  return new LiveMyMCPClient(config);\n}\n```\n\n## Example: Microsoft Learn MCP Server\n\nThe Microsoft Learn MCP Server (`https:\u002F\u002Flearn.microsoft.com\u002Fapi\u002Fmcp`) provides:\n\n### Tools\n\n1. `microsoft_docs_search` - Search Microsoft Learn documentation\n2. `microsoft_docs_fetch` - Fetch and convert a page to markdown\n3. `microsoft_code_sample_search` - Search code samples\n\n### Client Implementation\n\n```typescript\nexport interface DocSearchResult {\n  title: string;\n  url: string;\n  snippet: string;\n}\n\nexport interface MSLearnMCPClient {\n  readonly mode: \"mock\" | \"live\";\n  readonly isInitialized: boolean;\n\n  initialize(): Promise\u003CConnectorResult\u003Cvoid>>;\n  dispose(): Promise\u003Cvoid>;\n\n  searchDocs(query: string): Promise\u003CConnectorResult\u003CDocSearchResult[]>>;\n  fetchDoc(url: string): Promise\u003CConnectorResult\u003Cstring>>;\n  searchCodeSamples(\n    query: string,\n    language?: string,\n  ): Promise\u003CConnectorResult\u003CCodeSampleResult[]>>;\n}\n```\n\n## Testing Requirements\n\nEvery MCP client must include:\n\n1. Unit tests using Vitest\n2. Tests for initialization\u002Fdisposal\n3. Tests for each tool method\n4. Tests for error handling (NOT_INITIALIZED, etc.)\n\n```typescript\ndescribe(\"MyMCPClient\", () => {\n  let client: MyMCPClient;\n\n  beforeEach(async () => {\n    client = createMyMCPClient({ mode: \"mock\" });\n    await client.initialize();\n  });\n\n  afterEach(async () => {\n    await client.dispose();\n  });\n\n  it(\"should initialize successfully\", () => {\n    expect(client.isInitialized).toBe(true);\n  });\n\n  it(\"should fail when not initialized\", async () => {\n    const uninit = createMyMCPClient({ mode: \"mock\" });\n    const result = await uninit.toolName({});\n    expect(result.success).toBe(false);\n    expect(result.error?.code).toBe(\"NOT_INITIALIZED\");\n  });\n});\n```\n\n## File Structure\n\n```\nshared\u002Fconnectors\u002F\u003Cname>\u002F\n├── client.ts    # Client implementation\n└── index.ts     # Public exports\n\ntest\u002Fconnectors\u002F\n└── \u003Cname>.test.ts\n```\n\n## Acceptance Criteria\n\nA valid MCP client implementation must:\n\n1. ✅ Export a factory function `create\u003CName>Client(config)`\n2. ✅ Support both `mock` and `live` modes\n3. ✅ Use `ConnectorResult\u003CT>` for all async operations\n4. ✅ Have `isInitialized` property\n5. ✅ Return `NOT_INITIALIZED` error when called before `initialize()`\n6. ✅ Include comprehensive unit tests\n7. ✅ Follow existing connector patterns in the codebase\n",{"name":5,"license":15,"metadata":36,"description":7,"compatibility":39},{"author":37,"version":38},"copilot-sdk-samples","1.0","Requires TypeScript, Node.js 18+","main","5962839923b7d84f97dbc03a7872e8a56751a460","samples\u002Fskill-testing\u002Fsdk\u002Fskills\u002Fmcp-builder",9,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fcopilot-sdk-samples","https:\u002F\u002Fcopilot-sdk-samples.coreai.diy","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-09-13 05:34:50",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add microsoft\u002Fcopilot-sdk-samples --skill mcp-builder",{"tool":56,"command":57},"bunx","bunx skills add microsoft\u002Fcopilot-sdk-samples --skill mcp-builder",{"tool":59,"command":60},"pnpm","pnpm dlx skills add microsoft\u002Fcopilot-sdk-samples --skill mcp-builder","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fcopilot-sdk-samples\u002Fblob\u002Fmain\u002Fsamples\u002Fskill-testing\u002Fsdk\u002Fskills\u002Fmcp-builder\u002FSKILL.md",true,[],[]]