MCP Server
MCP 서버 - MCP 서버 구축을 위한 계층형 노드 패키지
이 라이브러리는 Node In Layers를 사용하여 MCP 서버를 쉽게 생성할 수 있는 기능을 추가합니다.
MCP 클라이언트를 생성하는 데 사용되는 '@node-in-layers/mcp-client'라는 보조 라이브러리가 있습니다. 이 두 라이브러리는 모델과 도구를 정의하는 데 동일한 함수를 공유합니다.
새 레이어
이 라이브러리는 시스템에 새로운 레이어인 mcp 추가합니다. 이 레이어는 express 레이어 뒤에 배치해야 합니다.
Related MCP server: Node Omnibus MCP Server
용법
이 라이브러리를 사용하려면 구성에 추가해야 하며 앱/도메인에서 "mcp" 레이어를 만들어 내보내야 합니다.
구성
이 앱/도메인을 설정 파일에 추가하세요. 앱을 추가하기 전에 이 작업을 수행해야 MCP 서버에 도구가 추가됩니다.
그런 다음 다음을 사용하여 mcp 앱/도메인을 구성합니다.
지엑스피1
MCP 레이어 생성
앱/도메인에서 레이어를 반환하는 함수를 내보내어 MCP 레이어를 만들 수 있습니다.
// /src/yourDomain/mcp.ts
import { McpContext, McpNamespace } from '@node-in-layers/mcp-server'
import { Config } from '@node-in-layers/core'
import { YourFeaturesLayer } from './features.js'
const create = (context: McpContext<Config, YourFeaturesLayer>) => {
// Adds your tool.
context.mcp[McpNamespace].addTool({
name: 'my-hello-world-tool',
description: 'My Tool',
execute: async (input: any) => {
return 'Hello, world!'
},
})
// Create a tool from your feature
context.mcp[McpNamespace].addTool({
name: 'my-hello-world-tool',
description: 'My Tool',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
},
},
required: ['name'],
},
execute: (input: any) => {
// You get an object, pass it back to your feature. Handles async for you.
return context.features.yourDomain.yourFeature(input)
},
})
return {}
}
export { create }모델 추가
모델을 CRUDS 함수로 래핑하고 mcp 레이어를 통해 MCP 서버에 추가할 수 있습니다. 참고: 이 기능을 사용하려면 레이어에 모델 외에도 서비스 레이어와 기능 레이어가 모두 있어야 합니다. 레이어의 노드는 모델과 함께 자동으로 CRUDS 속성을 생성하며, 이를 추가할 수 있습니다.
한 번에 하나씩 하는 예는 다음과 같습니다. (일반적으로 권장하지는 않지만, 실행 가능합니다).
// /src/yourDomain/mcp.ts
import { McpContext, McpNamespace } from '@node-in-layers/mcp-server'
import { Config } from '@node-in-layers/core'
import { YourFeaturesLayer } from './features.js'
const create = (context: McpContext<Config, YourFeaturesLayer>) => {
// Adds your models cruds through features.
context.mcp[McpNamespace].addModelCruds(
context.features.yourFeature.cruds.Cars
)
return {}
}가스로 제대로 요리하는 방법을 소개합니다. (강력 추천)
// /src/yourDomain/mcp.ts
import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server'
import { Config } from '@node-in-layers/core'
import { YourFeaturesLayer } from './features.js'
const create = (context: McpContext<Config, YourFeaturesLayer>) => {
// This automatically adds ALL of your models from features.
mcpModels('yourDomain')(context)
return {}
}모델 추가를 구성하는 또 다른 방법은 중앙 집중식 MCP 도메인을 사용하는 것입니다. 다른 모든 도메인이 로드된 후 이 도메인을 마지막 도메인으로 지정하세요.
// /src/mcp/mcp.ts
import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server'
import { Config } from '@node-in-layers/core'
const create = (context: McpContext<Config>) => {
// Add all your models for your whole system in one go.
mcpModels('yourDomain')(context)
mcpModels('yourDomain2')(context)
mcpModels('yourDomain3')(context)
mcpModels('yourDomain4')(context)
return {}
}This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Node-In-Layers/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server