mcp-z/client

mcp-z-client

Use @mcp-z/client from Node.js code.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/mcp-z/client --skill mcp-z-client

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

@mcp-z/client

@mcp-z/client manages MCP server configuration, process startup, connections, discovery, calls, and cleanup. Use the package's wrappers for ordinary tool, prompt, and resource calls. Reach for the raw MCP SDK responses only when the wrapper omits data the caller needs.

Install

bash
npm install @mcp-z/client

Read the consuming project's existing MCP configuration before inventing one. A standard .mcp.json stores entries under mcpServers.

Use the client

HTTP entries include type: 'http'. Stdio entries use command and optional args and env.

registry.close() closes every managed client and spawned process. Keep it in finally, or use await using registry = createServerRegistry(config) when the consuming runtime and project conventions support explicit resource management.

Tool names and schemas belong to the connected server, not this skill. Call client.listTools() before composing an unfamiliar invocation and use the returned input schema. Discovery is read-only. A tool call may change external state, so the call must stay within the user's requested action.

The convenience methods accept simple arguments:

  • client.callTool(name, args)
  • client.getPrompt(name, args)
  • client.readResource(uri)

Their response wrappers expose json(), text(), and raw(). For tools, json() returns structuredContent when present and otherwise parses the first text block. Wrapper methods throw a typed response error for MCP error results or incompatible content.

Use callToolRaw(), getPromptRaw(), or readResourceRaw() only when the caller needs the untouched SDK response.

Examples

Connection options

createServerRegistry(config, { cwd, env, dialects }) controls spawned processes. Supplying env replaces the base environment rather than merging with process.env.

The default dialects: ['servers'] starts stdio command entries. An HTTP entry with a start block needs dialects: ['start'], or ['servers', 'start'] when both forms should start.

registry.connect(name, { versionNegotiation: { mode: 'auto' } }) probes for the current protocol revision and falls back to the legacy sequence. Pin a revision only when the caller requires that exact protocol.

관련 작업