ข้ามไปยังเนื้อหา
AggregaAggregaAggregaAggrega
เลือกภาษา: ไทย
หน้านี้ถูกแปลด้วยเครื่อง อ่านต้นฉบับภาษาอังกฤษ

นำเข้าการกำหนดค่าไคลเอนต์ MCP

บทแนะนำทีละขั้นตอนนี้นำเข้าเซิร์ฟเวอร์ Model Context Protocol ที่ผู้ช่วยเขียนโค้ดกำหนดค่าไว้ ซึ่งเป็นเซิร์ฟเวอร์สองตัวที่ผู้ช่วยเริ่มจากบรรทัดคำสั่ง และอีกหนึ่งตัวที่ผู้อื่นรัน และบิลด์เซิร์ฟเวอร์เหล่านั้นสำหรับ Kubernetes เพื่อให้เอเจนต์ที่รันในคลัสเตอร์เข้าถึงเครื่องมือเดียวกันได้ การนำเข้าร่างทุกไฟล์ที่บิลด์อ่าน ได้แก่ บรรทัดคำสั่งหรือที่อยู่ของเซิร์ฟเวอร์แต่ละตัว การทำให้เป็นรูปธรรมที่รันเซิร์ฟเวอร์นั้น และที่มาของโทเค็นของเซิร์ฟเวอร์ GitHub ทุกไฟล์และทุกบล็อกเอาต์พุตด้านล่างมาจากการรันจริง การกำหนดค่าและแต่ละขั้นตอนของบทแนะนำอยู่ในตัวอย่าง import-mcp ซึ่งสคริปต์ตรวจสอบรันการนำเข้าอีกครั้ง เปรียบเทียบสิ่งที่การนำเข้าเขียน สิ่งที่พิมพ์ และบล็อกที่หน้านี้อ้างถึงกับไฟล์ที่เก็บไว้ที่นั่น แล้วตรวจสอบความถูกต้องและบิลด์สิ่งที่การนำเข้าเขียน

ร่างตัวอย่าง

คุณรันการนำเข้านี้ด้วยคำสั่งในหน้านี้ได้ หรือ ให้ผู้ช่วย AI ของคุณรันให้

เขียนตัวอย่างลงในโฟลเดอร์ใหม่ที่ตั้งชื่อตามตัวอย่าง:

Terminal window
aggrega draft --example import-mcp

จากนั้นจะพิมพ์คำสั่งที่ต้องรันต่อ คำสั่งแรกเปลี่ยนเข้าโฟลเดอร์ใหม่ ส่วนคำสั่งถัดไปด้านล่างเปลี่ยนเข้าโฟลเดอร์ source ซึ่งมีสิ่งที่หน้านี้นำเข้าและเป็นที่ที่การนำเข้ารัน:

Terminal window
cd import-mcp

โฟลเดอร์ source ของตัวอย่างที่ร่างไว้เปิดอยู่ใน Visual Studio Code แสดงการกำหนดค่า MCP ของตัวอย่างซึ่งมีเซิร์ฟเวอร์สามตัว: github, fetch และ docs-search

การกำหนดค่า

ไฟล์ .mcp.json ของ Claude Code ที่รากของโปรเจกต์:

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
}
},
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"]
},
"docs-search": {
"type": "http",
"url": "https://mcp.example.com/docs/mcp",
"headers": {
"Authorization": "Bearer ${DOCS_API_KEY}"
}
}
}
}

การนำเข้าอ่าน claude_desktop_config.json ของ Claude Desktop, .cursor/mcp.json ของ Cursor, .vscode/mcp.json ของ Visual Studio Code และ server.json ของรีจิสทรี MCP ในลักษณะเดียวกัน ข้างการกำหนดค่า .aggrega-config.yaml ทำให้โฟลเดอร์เป็นพื้นที่ทำงาน:

# The workspace key marks this directory as the workspace root, so an import run
# here writes its drafts beside .mcp.json.
workspace: {}
# The registry the importer is fetched from the first time an import needs it.
default_registry: hub.aggrega.ai

--target ร่าง Manifest จาก Recipes ของแค็ตตาล็อก พื้นที่ทำงานไม่ระบุโฟลเดอร์แค็ตตาล็อก การนำเข้าจึงอ่านแค็ตตาล็อกไลบรารีมาตรฐานจากรีจิสทรีที่ดึงตัวนำเข้ามา คือสแนปช็อตที่ลงลายเซ็นของแค็ตตาล็อกที่เผยแพร่ ซึ่งการนำเข้าครั้งแรกดึงมา ยืนยัน และเก็บไว้ในแคชเนื้อหาของพื้นที่ทำงาน และระบุด้วยไดเจสต์ในบันทึกที่การนำเข้าเขียนไว้ข้างร่าง พื้นที่ทำงานที่ระบุโฟลเดอร์แค็ตตาล็อกของตนเอง ใน AGGREGA_CATALOG_DIRS หรือใต้ workspace.catalog_dirs จะนำเข้าเทียบกับโฟลเดอร์เหล่านั้นแทน

ไฟล์คำตอบ

บน Kubernetes เซิร์ฟเวอร์ GitHub อ่านโทเค็นจาก Secret ที่คลัสเตอร์มี และไม่มีการกำหนดค่า MCP ใดระบุ Secret นั้น: การกำหนดค่าอ่านโทเค็นจาก GITHUB_TOKEN ของ shell ของคุณ การนำเข้าจึงถามหาชื่อของ Secret ตัวอย่างเก็บคำตอบไว้ใน import-answers.yaml ข้าง .mcp.json ซึ่งเป็นที่ที่การนำเข้าค้นหา:

# Values the import could not draft from the source, keyed by the drafted file and the key path inside
# it. Write each one beside its key; an import of the same source, and a sync, read them from here and
# ask nothing. A secret is never written here: its key asks where the secret comes from — a variable
# name, ${NAME}, or the name of a Kubernetes Secret.
release.yaml:
# The origin of the secret value, written by the operator in the Release. Read exactly as
# values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes
# from, never the value.
spec.components.github.features.server_env.infra.origin: "github-mcp-token"

การนำเข้าเขียนไฟล์นี้เอง ในครั้งแรกที่รันโดยไม่มีคำตอบ: เมื่อไม่มีเทอร์มินัลให้ถาม การนำเข้าร่างทุกอย่างอื่น ปล่อยชื่อของ Secret ว่างไว้ แสดงคีย์ในไฟล์ และหยุดพร้อมกับ

1 value the drafts leave empty is still owed, listed in the answers file <workspace>/import-answers.yaml: write it beside its key there, then run the import again

ที่เทอร์มินัล การนำเข้าจะถามคำถามแทน และเขียนคำตอบลงในไฟล์สำหรับการนำเข้าครั้งถัดไป คำตอบคือชื่อของ Secret คือ github-mcp-token ไม่ใช่โทเค็น ไฟล์คำตอบของการนำเข้า อธิบายไฟล์และคำถามโดยละเอียด

aggrega import ระบุทุกแฟล็กที่คำสั่งรับ รวมถึง --answers ซึ่งระบุไฟล์คำตอบที่เก็บไว้ที่อื่น

เปลี่ยนเข้าโฟลเดอร์ source:

Terminal window
cd source

รันการนำเข้า

Terminal window
aggrega import .mcp.json --target helm

ที่เอาต์พุตมาตรฐาน การนำเข้าแสดงสิ่งที่เขียน:

wrote aggregate.yaml
wrote release.yaml
wrote manifest.yaml
wrote .aggrega-import.json

ที่ข้อผิดพลาดมาตรฐาน โดยที่ <workspace> แทนโฟลเดอร์ที่คุณรัน:

[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]
read as the mcp format, with drafted paths relative to <workspace>
warn: the value of infra.stdio_command.0 of node github is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of infra.stdio_command.1 of node github is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of infra.stdio_command.2 of node github is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of infra.stdio_command.0 of node fetch is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of infra.stdio_command.1 of node fetch is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of headers.Authorization of node docs-search is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
warn: the value of infra.endpoint of node docs-search is carried as written in the Release the draft writes: the field belongs to an MCP server's configuration, which can carry a key, and setting empty_credentials to marked or all writes it empty
Pull complete: <workspace>/release.lock (entities=7, source_artifacts=0, external_inputs=0)

การนำเข้าที่รันจากตัวแก้ไข: Aggregate, Release และ Manifest ที่ร่างไว้ปรากฏข้างการกำหนดค่า MCP Aggrega output แสดงรายการค่าที่พาไปตามที่เขียนและไฟล์ที่เขียน และการแจ้งเตือนระบุว่าการนำเข้าร่างไฟล์ 3 ไฟล์ โดยรู้จักเป็น mcp

เซิร์ฟเวอร์ทุกตัวเป็นอินสแตนซ์ของเครื่องมือ MCP ในไลบรารีมาตรฐาน คือ core/ai-tool/mcp การนำเข้าจึงไม่ชั่งน้ำหนักตัวเลือกใดและไม่พิมพ์บรรทัด mapped

  • บรรทัด warn ระบุค่าที่การกำหนดค่าของเซิร์ฟเวอร์มี ไคลเอนต์ MCP ไม่ทำเครื่องหมายค่าใดเลยว่าเป็นข้อมูลรับรอง และค่าใดค่าหนึ่งก็อาจมีข้อมูลรับรองอยู่ได้ เช่นคีย์ในอาร์กิวเมนต์บรรทัดคำสั่ง หรือโทเค็นในที่อยู่ การนำเข้าจึงระบุแต่ละรายการของบรรทัดคำสั่ง แต่ละเฮดเดอร์ และแต่ละที่อยู่ที่เซิร์ฟเวอร์มี ด้วยชื่อเซิร์ฟเวอร์และตำแหน่ง ไม่ระบุด้วยค่าเลย อ่านบรรทัดเหล่านี้ก่อนใช้ร่างร่วมกับผู้อื่น ค่า ${GITHUB_TOKEN} ของ env เป็นการอ้างอิงตัวแปรและไม่มีอะไรอื่น จึงไม่มีค่าของตัวเองและไม่มีคำเตือนใดระบุค่านี้
  • บรรทัด Pull complete คือการนำเข้าดึงสิ่งที่ Release ที่ร่างพึ่งพา เหมือนที่ aggrega pull ทำ ลงใน release.lock ฉบับร่างจึงตรวจสอบความถูกต้องและบิลด์ได้ทันที ภายใต้ --offline การนำเข้าไม่ pull สิ่งใดและระบุ aggrega pull ที่ต้องรัน

สิ่งที่การนำเข้าเขียน

Aggregate, Release และ Manifest ตั้งชื่อว่า imported/mcp ตามไฟล์ คือ .mcp.json เพราะการกำหนดค่าของไคลเอนต์ไม่มีชื่อของตัวเอง (server.json ของรีจิสทรีตั้งชื่อตาม name ของไฟล์นั้น) ภายใต้เนมสเปซที่การตั้งค่า target_namespace ของตัวนำเข้ากำหนด คือ imported เว้นแต่คุณตั้งค่าอื่น (การตั้งค่า)

aggregate.yaml ประกอบด้วยหนึ่งอินสแตนซ์ต่อเซิร์ฟเวอร์ และยังไม่มีสิ่งใดที่ใช้อินสแตนซ์เหล่านั้น:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: imported/mcp
version: 0.1.0
description: Draft Aggregate imported from a source in the mcp format.
spec:
components:
github:
type: core/ai-tool/mcp
fetch:
type: core/ai-tool/mcp
docs-search:
type: core/ai-tool/mcp

release.yaml ประกอบด้วยวิธีรันหรือเข้าถึงเซิร์ฟเวอร์แต่ละตัวตามที่การกำหนดค่าระบุ และ Secret ที่ใช้อ่านโทเค็นของเซิร์ฟเวอร์ GitHub:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: imported/mcp
# environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to.
environment: development
version: 0.1.0
description: Draft Release imported from a source in the mcp format.
spec:
aggregate: imported/mcp
manifest: imported/mcp
components:
github:
infra:
stdio_command:
- "npx"
- "-y"
- "@modelcontextprotocol/server-github"
stdio_runtime: npm
features:
server_env:
type: core/referenced-secret
infra:
# Left for the Release, since the source cannot supply it: the name of a Kubernetes Secret already in the namespace holding the environment github is started with, one data key per variable, each named as the variable it holds: GITHUB_PERSONAL_ACCESS_TOKEN.
origin: "github-mcp-token"
fetch:
infra:
stdio_command:
- "uvx"
- "mcp-server-fetch"
stdio_runtime: pypi
# The headers the source sends this server, which no infrastructure key of core/ai-tool/mcp takes, since a remote server's credential is held by each consumer, on its connection to the tool:
# - Authorization: "Bearer ${DOCS_API_KEY}"
docs-search:
infra:
endpoint: "https://mcp.example.com/docs/mcp"
  • สภาพแวดล้อม development เป็นค่าเริ่มต้นที่การนำเข้าเขียนเพราะไม่มีการกำหนดค่าใดระบุไว้ เปลี่ยนค่านี้ถ้า Release ปรับใช้ที่อื่น
  • stdio_runtime อ่านจากแต่ละคำสั่ง: npx รันแพ็กเกจ npm ส่วน uvx รันแพ็กเกจ PyPI
  • โทเค็น GitHub สภาพแวดล้อมของเซิร์ฟเวอร์กลายเป็นสล็อต server_env ของเซิร์ฟเวอร์ บน Kubernetes การทำให้เป็นรูปธรรมของ core/referenced-secret-set คือ helm/k8s-secret-set เขียนค่าที่ได้รับลงใน Secret ที่บิลด์เรนเดอร์ ซึ่งจะทำให้โทเค็นอยู่ในไฟล์ ดังนั้นสำหรับ --target helm การนำเข้าจึงแนบ core/referenced-secret แทน โดยระบุ Secret ที่คลัสเตอร์มีอยู่แล้ว คือคำตอบ github-mcp-token พร้อมคีย์ข้อมูลหนึ่งคีย์ต่อตัวแปร คือ GITHUB_PERSONAL_ACCESS_TOKEN บริดจ์นำเข้าคีย์ข้อมูลทุกคีย์ของ Secret นั้นเป็นตัวแปรชื่อเดียวกัน เซิร์ฟเวอร์จึงอ่านโทเค็นเหมือนที่อ่านบนเครื่องของคุณ และไม่มีไฟล์ที่เรนเดอร์ออกมาใดมีโทเค็นอยู่เลย
  • เฮดเดอร์ Authorization ยังคงเป็นความคิดเห็น ข้อมูลรับรองของเซิร์ฟเวอร์ระยะไกลอยู่กับผู้เรียกเซิร์ฟเวอร์นั้น บนการเชื่อมต่อของผู้เรียกเองไปยังเครื่องมือ และพื้นที่ทำงานนี้ยังไม่มีผู้เรียก เมื่อคุณเชื่อมโยงเอเจนต์กับ docs-search เฮดเดอร์จะอยู่บนการเชื่อมต่อนั้น

manifest.yaml ประกอบด้วยการทำให้เป็นรูปธรรมหนึ่งรายการต่อเซิร์ฟเวอร์ ตามชื่อของเซิร์ฟเวอร์ และการทำให้เป็นรูปธรรมของ Secret:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/mcp
version: 0.1.0
spec:
mappings:
components:
type: {}
name:
github: helm/mcp-stdio-bridge
fetch: helm/mcp-stdio-bridge
docs-search: helm/mcp-remote
features:
type:
core/referenced-secret: helm/k8s-existing-secret

Recipes สำหรับ Kubernetes สามรายการทำให้ core/ai-tool/mcp เป็นจริง ได้แก่ รายการหนึ่งสำหรับเซิร์ฟเวอร์ที่เผยแพร่เป็นอิมเมจ รายการหนึ่งสำหรับแพ็กเกจที่รันหลังบริดจ์ และรายการหนึ่งสำหรับเซิร์ฟเวอร์ที่ผู้อื่นรัน และรายการใดที่เหมาะเป็นลักษณะเฉพาะของเซิร์ฟเวอร์แต่ละตัว ซึ่งการกำหนดค่าระบุ การนำเข้าจึงแมปแต่ละอินสแตนซ์ตามชื่อ: github และ fetch ซึ่งเริ่มจากบรรทัดคำสั่ง รันหลังบริดจ์ stdio คือ helm/mcp-stdio-bridge ส่วน docs-search ซึ่งผู้อื่นรัน แมปไปยัง helm/mcp-remote ซึ่งไม่รันอะไรและเผยแพร่ที่อยู่ Secret ของโทเค็นแมปไปยัง helm/k8s-existing-secret ซึ่งอ้างอิง Secret แทนการเขียน Secret ขึ้นใหม่

release.lock บันทึกเอนทิตีในแค็ตตาล็อกที่ Release หาค่าได้ ตามไดเจสต์ และ .aggrega-import.json เป็นบันทึกของสิ่งที่การนำเข้าเขียน ซึ่ง aggrega import --sync ครั้งต่อไปอ่าน

บน Docker Compose

เซิร์ฟเวอร์รันบน Docker Compose ได้เช่นกัน aggrega import .mcp.json --target compose แมป github และ fetch ไปยัง compose/mcp-stdio-bridge และแมป docs-search ไปยัง compose/mcp-remote และคงสภาพแวดล้อมของเซิร์ฟเวอร์ GitHub ไว้ตามที่การกำหนดค่าเขียน คือรายการ core/referenced-secret-set ที่มีค่าเป็นการอ้างอิงตัวแปร ${GITHUB_TOKEN} ซึ่ง compose/dotenv-secret-set ทำให้เป็นรูปธรรม โดยเขียนลงในสภาพแวดล้อมของบริการตามที่เขียนไว้ Docker Compose จึงเติมค่านี้จาก shell ของคุณเมื่อสแตกเริ่มทำงาน การนำเข้านั้นไม่ถามหาอะไร และเก็บชื่อของ Secret ไว้ในไฟล์คำตอบโดยไม่ใช้

ตรวจสอบความถูกต้องและบิลด์

Terminal window
aggrega validate --release release.yaml
aggrega build --release release.yaml

Release ที่ร่างไว้เปิดอยู่ในตัวแก้ไขหลังตรวจสอบความถูกต้อง โดย Aggrega output และการแจ้งเตือนต่างรายงานว่าไม่พบปัญหา

บิลด์ของ Release ที่ร่างไว้: โฟลเดอร์ dist ปรากฏใน Explorer โดย Aggrega output แสดงรายการ Deployment และ Service ของเซิร์ฟเวอร์แต่ละตัว และการแจ้งเตือนระบุว่าเขียนไฟล์ 5 ไฟล์

การตรวจสอบความถูกต้องพิมพ์:

notice: LINT: Feature "core/referenced-secret" at core/referenced-secret:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)

และบิลด์ โดยที่ <workspace> แทนโฟลเดอร์ที่คุณรัน:

notice: LINT: Feature "core/referenced-secret" at core/referenced-secret:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
[… omitted: a total build time, which differs per run]
Build completed: 5 files written to <workspace>/dist

บรรทัด notice เป็นเชิงแนะนำ: Feature รับ origin จาก values ของ Aggregate หรือ infra ของ Release และข้อแนะนำนี้รายงานว่ามีลีฟหนึ่งรายการประกาศไว้ทั้งสองแห่ง ไม่เปลี่ยนคำตัดสิน

บิลด์เขียน Deployment และ Service สำหรับเซิร์ฟเวอร์ที่ผ่านบริดจ์แต่ละตัวจากสองตัว และ Service หนึ่งรายการสำหรับ docs-search ไว้ใต้ dist/helm/ คอนเทนเนอร์ของเซิร์ฟเวอร์ GitHub ใน dist/helm/github-deployment.yaml รันบริดจ์ด้วยบรรทัดคำสั่งของเซิร์ฟเวอร์ และรับสภาพแวดล้อมจาก Secret:

containers:
- name: main
image: ghcr.io/supercorp-ai/supergateway:4.1.0@sha256:1938c43538a5308bce07d58028e9de00b7acfecb40b39b059b2f3931800ad910
args:
- --stdio
- '''npx'' ''-y'' ''@modelcontextprotocol/server-github'''
- --outputTransport
- streamableHttp
- --stateful
- --port
- "8080"
- --streamableHttpPath
- /mcp
- --healthEndpoint
- /healthz
ports:
- name: http
containerPort: 8080
env:
- name: MCP_TOOL_SIDE_EFFECTS
value: mutating
- name: MCP_TOOL_TIMEOUT_SECONDS
value: "30"
- name: MCP_TOOL_PORT
value: "8080"
envFrom:
- secretRef:
name: github-mcp-token
[… omitted: the container's resources and its readiness probe]

dist/helm/docs-search-service.yaml ไม่รันอะไร: ไฟล์นี้ตั้งชื่อภายในคลัสเตอร์ให้เซิร์ฟเวอร์ที่ผู้อื่นรัน

apiVersion: v1
kind: Service
metadata:
name: docs-search
[… omitted: the labels and annotations the build writes on every resource]
spec:
type: ExternalName
externalName: mcp.example.com
ports:
- port: 443

กับผู้ช่วย AI

ผู้ช่วย AI ที่ ตั้งค่าด้วยเครื่องมือของ Aggrega ทำสิ่งเดียวกันได้: วางพรอมต์นี้ลงไป

ใช้เฉพาะเครื่องมือของ Aggrega และอย่าสร้างโฟลเดอร์เอง ถ้าโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `import-mcp` เรียกเครื่องมือ `draft` หนึ่งครั้ง โดยตั้ง `example` เป็น `import-mcp` และไม่ระบุ `dir`: เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `import-mcp` ใหม่ ซึ่งโฟลเดอร์ `source` ของโฟลเดอร์นั้นเก็บสิ่งที่หน้านี้นำเข้า จากนั้นเรียกเครื่องมือ `import` โดยตั้ง `workspace_root` เป็น `import-mcp/source` ตั้ง `source` เป็น `.mcp.json` และตั้ง `target` เป็น `helm`: เครื่องมืออ่านคำตอบที่ต้องใช้จาก `import-answers.yaml` ข้าง `.mcp.json` เขียนร่างลงใน `import-mcp/source` และ pull สิ่งที่ร่างเหล่านั้นต้องใช้ จากนั้นเรียกเครื่องมือ `validate` โดยตั้ง `workspace_root` เป็น `import-mcp/source` และตั้ง `release` เป็น `release.yaml` และเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `import-mcp/source` ตั้ง `release` เป็น `release.yaml` และตั้ง `write` เป็น true บอกฉันว่าบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `import-mcp/source/dist/`

เปิดใน VS Code

เมื่อติดตั้ง ส่วนขยาย Aggrega สำหรับ Visual Studio Code แล้ว เปิดโฟลเดอร์ import-mcp/source ใน VS Code ซึ่งเป็นที่ที่การนำเข้าเขียนร่างไว้ โฟลเดอร์มี Release หนึ่งรายการคือ release.yaml ที่ร่างไว้ ตัวแก้ไขจึงเลือก Release นั้นให้คุณ และตรวจสอบร่างเทียบกับ Release นั้นขณะที่คุณแก้ไข โดยทำเครื่องหมายสิ่งที่พบในไฟล์และในแผง Problems Aggrega: Show topology graph ใน Command Palette วาดส่วนประกอบของ Release และการเชื่อมต่อระหว่างส่วนประกอบเหล่านั้น Aggrega: Build, Aggrega: Preview build และ Aggrega: Pull ทำงานกับ Release เดียวกัน และแต่ละคำสั่งยังเป็นปุ่มบนแผง Commands ของมุมมอง Aggrega ในแถบกิจกรรม Build เขียนไฟล์ลงใน dist/ ของโฟลเดอร์ ใช้ Aggrega ใน Visual Studio Code ครอบคลุมส่วนที่เหลือ

วิธีรัน

ไม่มีสิ่งใดในบิลด์เขียน Secret github-mcp-token จึงสร้าง Secret นั้นก่อนนำไฟล์ไปใช้ เขียนโทเค็นของคุณลงใน github-token.env เป็นบรรทัดเดียวคือ GITHUB_PERSONAL_ACCESS_TOKEN=<your token> แล้วสร้าง Secret จากไฟล์นั้น เมื่อถึงตอนนั้นคลัสเตอร์เก็บโทเค็นไว้แล้ว จึงลบไฟล์:

Terminal window
kubectl create secret generic github-mcp-token --from-env-file=github-token.env
rm github-token.env
secret/github-mcp-token created

นำบิลด์ไปใช้ ตามที่ขั้นตอนรันใน วิธีที่การนำเข้าทำงาน อธิบายไว้ และรอเซิร์ฟเวอร์ทั้งสองตัว:

Terminal window
kubectl apply -R -f dist/helm/
kubectl wait --for=condition=Available deployment.apps/fetch deployment.apps/github --timeout=5m
service/docs-search created
service/fetch-default created
deployment.apps/fetch created
service/github-default created
deployment.apps/github created
deployment.apps/fetch condition met
deployment.apps/github condition met

บน Docker Compose ในพื้นที่ทำงานที่นำเข้าด้วย --target compose และบิลด์แล้ว เริ่มสแตกโดยใส่โทเค็นของคุณใน GITHUB_TOKEN ของ shell ซึ่ง Docker Compose อ่านเมื่อสแตกเริ่มทำงาน:

Terminal window
docker compose -p mcp -f dist/compose/docker-compose.yaml up -d --wait

ทดสอบ

บริดจ์ให้บริการเซิร์ฟเวอร์แต่ละตัวผ่านการขนส่ง Streamable HTTP ของ MCP ที่ /mcp บนพอร์ต 8080 เปิดเซสชันกับเซิร์ฟเวอร์ fetch ด้วยคำขอ initialize ของ MCP ซึ่งไม่อ่านโทเค็น

บน Docker Compose ส่งคำขอจากคอนเทนเนอร์ชั่วคราวบนเครือข่ายของสแตก คือ mcp_compose ซึ่งชื่อของเซิร์ฟเวอร์คือ fetch:

Terminal window
docker run --rm --network mcp_compose curlimages/curl:8.11.1 -sS http://fetch:8080/mcp \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "test-it", "version": "1.0.0"}}}'
: keepalive
[… omitted: the same comment, repeated while the server starts]
event: message
data: {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"prompts":{"listChanged":false},"resources":{"listChanged":false,"subscribe":false},"tools":{"listChanged":false}},"protocolVersion":"2025-06-18","serverInfo":{"name":"mcp-fetch","version":"2026.11.11"}}}

บน Kubernetes ส่งต่อพอร์ตภายในเครื่องไปยัง Service ของเซิร์ฟเวอร์ คือ fetch-default และปล่อยให้คำสั่งรันต่อไป:

Terminal window
kubectl port-forward svc/fetch-default 8080:8080

จากเทอร์มินัลอื่น ส่งคำขอเดียวกันไปยังพอร์ตที่ส่งต่อ:

Terminal window
curl -sS http://127.0.0.1:8080/mcp \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "test-it", "version": "1.0.0"}}}'
: keepalive
: keepalive
event: message
data: {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"prompts":{"listChanged":false},"resources":{"listChanged":false,"subscribe":false},"tools":{"listChanged":false}},"protocolVersion":"2025-06-18","serverInfo":{"name":"mcp-fetch","version":"2026.11.11"}}}

การตอบกลับระบุชื่อเซิร์ฟเวอร์ คือ mcp-fetch ใช้เวลาสักครู่: บริดจ์เริ่มบรรทัดคำสั่งของเซิร์ฟเวอร์ คือ uvx mcp-server-fetch สำหรับแต่ละเซสชัน และ uvx ดาวน์โหลดและติดตั้งแพ็กเกจของเซิร์ฟเวอร์ก่อน ซึ่งใช้เวลาราวครึ่งนาทีบน Kubernetes และราวหนึ่งนาทีบน Docker Compose ในการรันนี้ บรรทัด : keepalive คือความคิดเห็นที่สตรีมส่งมาในระหว่างนั้น

เซิร์ฟเวอร์ GitHub ตอบคำขอเดียวกันที่ http://github:8080/mcp บน Docker Compose และผ่าน kubectl port-forward svc/github-default 8080:8080 บน Kubernetes initialize ไม่อ่านโทเค็น จึงตอบไม่ว่าโทเค็นจะเป็นค่าใด การรันนี้ใช้โทเค็นตัวแทน:

[… omitted: the keepalive comments, sent while npx installs the server]
event: message
data: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"github-mcp-server","version":"0.6.2"}},"jsonrpc":"2.0","id":1}

หยุดการส่งต่อพอร์ต แล้วลบสิ่งที่คุณนำไปใช้และ Secret:

Terminal window
kubectl delete -R -f dist/helm/
kubectl delete secret github-mcp-token

บน Docker Compose หยุดและลบสแตก:

Terminal window
docker compose -p mcp -f dist/compose/docker-compose.yaml down