cskwork/keyword-rag-mcp
If you are the rightful owner of keyword-rag-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Knowledge Retrieval Server is designed for document search and retrieval using the BM25 algorithm, providing a structured and efficient way to manage and access information.
search-documents
Performs document search based on keywords.
get-document-by-id
Retrieves a document by its ID.
list-domains
Lists all available domains and document counts.
get-chunk-with-context
Retrieves a specific chunk and its surrounding context.
MCP Knowledge Retrieval Server
BM25 ๊ธฐ๋ฐ ๋ฌธ์ ๊ฒ์ ๋ฐ ๊ฒ์์ ์ํ MCP(Model Context Protocol) ์๋ฒ์ ๋๋ค.
- ์ฐธ๊ณ ํ ํ ์ค๊ฒฐ์ ์ฐ๋ MCP ๊ธฐ์ ๋ธ๋ก๊ทธ. https://toss.tech/article/tosspayments-mcp
๐ ์ฆ์ ์์ํ๊ธฐ
๐ฏ ์ด๊ฐ๋จ ์ค์น (๊ถ์ฅ)
# macOS/Linux
./run.sh
# Windows
run.bat
์ด ์คํฌ๋ฆฝํธ๋ค์ด ์๋์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค:
- โ Node.js ๋ฒ์ ํ์ธ
- โ
์์กด์ฑ ์ค์น (
npm install
) - โ
ํ๋ก์ ํธ ๋น๋ (
npm run build
) - โ
์ค์ ํ์ผ ์์ฑ (
config.json
) - โ
์์ ๋ฌธ์ ์์ฑ (
docs/
ํด๋) - โ Claude Desktop ์ค์ ๊ฐ์ด๋ ์ถ๋ ฅ
- โ MCP ์๋ฒ ์คํ
์๋ ์ค์น
# ๋จ๊ณ๋ณ ์ค์น
npm install && npm run build && cp config.example.json config.json
# ์๋ฒ ์คํ
npm start
๊ฐ๋ฐ ๋ชจ๋
npm run dev
๐ ๊ธฐ๋ณธ ์ค์
config.json (์๋ ์์ฑ๋จ)
{
"serverName": "knowledge-retrieval",
"serverVersion": "1.0.0",
"documentSource": {
"type": "local",
"basePath": "./docs",
"domains": [
{
"name": "company",
"path": "company",
"category": "ํ์ฌ์ ๋ณด"
},
{
"name": "customer",
"path": "customer",
"category": "๊ณ ๊ฐ์๋น์ค"
},
{
"name": "product",
"path": "product",
"category": "์ ํ์ ๋ณด"
},
{
"name": "technical",
"path": "technical",
"category": "๊ธฐ์ ๋ฌธ์"
}
]
},
"bm25": {
"k1": 1.2,
"b": 0.75
},
"chunk": {
"minWords": 30,
"contextWindowSize": 1
},
"logLevel": "info"
}
์ฃผ์ ์ค์ ํญ๋ชฉ
- documentSource.basePath: ๋ฌธ์ ํ์ผ๋ค์ด ์์นํ ๊ธฐ๋ณธ ๊ฒฝ๋ก
- domains: ๊ฒ์ํ ๋๋ฉ์ธ๋ค์ ์ค์
- bm25.k1: BM25 ์๊ณ ๋ฆฌ์ฆ์ term frequency saturation ํ๋ผ๋ฏธํฐ (๊ธฐ๋ณธ๊ฐ: 1.2)
- bm25.b: BM25 ์๊ณ ๋ฆฌ์ฆ์ field length normalization ํ๋ผ๋ฏธํฐ (๊ธฐ๋ณธ๊ฐ: 0.75)
- chunk.minWords: ์ฒญํฌ์ ์ต์ ๋จ์ด ์ (๊ธฐ๋ณธ๊ฐ: 30)
๐ง Claude Desktop ์ฐ๋
์ค์ ํ์ผ ์์น
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%/Claude/claude_desktop_config.json
์ค์ ๋ด์ฉ (์ ๋ ๊ฒฝ๋ก)
{
"mcpServers": {
"knowledge-retrieval": {
"command": "node",
"args": ["<ํ๋ก์ ํธ_๊ฒฝ๋ก>/dist/index.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
์ค์: <ํ๋ก์ ํธ_๊ฒฝ๋ก>
๋ฅผ ์ค์ ํ๋ก์ ํธ ํด๋์ ์ ๋ ๊ฒฝ๋ก๋ก ๋ฐ๊พธ์ธ์!
๊ถ์ฅ ์ค์ (์์ ๋๋ ํ ๋ฆฌ ์ง์ )
{
"mcpServers": {
"knowledge-retrieval": {
"command": "npm",
"args": ["start"],
"cwd": "<ํ๋ก์ ํธ_๊ฒฝ๋ก>"
}
}
}
๐ ๋ฌธ์ ๊ตฌ์กฐ
๋ฌธ์๋ ๋ค์๊ณผ ๊ฐ์ ๊ตฌ์กฐ๋ก ๊ตฌ์ฑ๋์ด์ผ ํฉ๋๋ค:
docs/
โโโ company/ # ํ์ฌ ์ ๋ณด
โ โโโ about.md
โ โโโ team.md
โโโ customer/ # ๊ณ ๊ฐ ์๋น์ค
โ โโโ support.md
โ โโโ sla.md
โโโ product/ # ์ ํ ์ ๋ณด
โ โโโ ai-platform.md
โ โโโ web-app.md
โโโ technical/ # ๊ธฐ์ ๋ฌธ์
โโโ api-guide.md
โโโ deployment.md
์ง์ ํ์ผ ํ์
.md
(Markdown).mdx
(MDX).markdown
๐ ์ฌ์ฉ ๊ฐ๋ฅํ MCP ๋๊ตฌ๋ค
1. search-documents
๋ฌธ์ ๊ฒ์์ ์ํํฉ๋๋ค.
ํ๋ผ๋ฏธํฐ:
keywords
: ๊ฒ์ํ ํค์๋ ๋ฐฐ์ดmaxResults
: ์ต๋ ๊ฒฐ๊ณผ ์ (๊ธฐ๋ณธ๊ฐ: 10)domain
: ํน์ ๋๋ฉ์ธ์ผ๋ก ๊ฒ์ ์ ํ (์ ํ์ฌํญ)
์์:
// Claude Desktop์์ ์ฌ์ฉํ ๋
"AI ํ๋ซํผ์ ๊ฐ๊ฒฉ ์ ์ฑ
์ ์๋ ค์ค"
2. get-document-by-id
ํน์ ๋ฌธ์ ID๋ก ์ ์ฒด ๋ฌธ์๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
ํ๋ผ๋ฏธํฐ:
documentId
: ๋ฌธ์ ID
3. list-domains
์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ ๋๋ฉ์ธ๊ณผ ๋ฌธ์ ์๋ฅผ ์กฐํํฉ๋๋ค.
4. get-chunk-with-context
ํน์ ์ฒญํฌ์ ๊ทธ ์ฃผ๋ณ ์ปจํ ์คํธ๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
ํ๋ผ๋ฏธํฐ:
chunkId
: ์ฒญํฌ IDcontextSize
: ์ปจํ ์คํธ ์๋์ฐ ํฌ๊ธฐ (์ ํ์ฌํญ)
๐งช ํ ์คํธ ๋ฐ ๊ฒ์ฆ
1. ์๋ฒ ์๋ ํ์ธ
npm run dev
โ ์ฑ๊ณต์ ์ถ๋ ฅ ์์:
Initializing knowledge-retrieval v1.0.0...
Loaded 8 documents
Initialized repository with 36 chunks from 8 documents
MCP server started successfully
2. Claude Desktop์์ ์ฆ์ ํ ์คํธ
Claude Desktop ์ฌ์์ ํ ๋ค์ ์ง๋ฌธ๋ค๋ก ํ ์คํธ:
์ฐ๋ฆฌ ํ์ฌ์ ๋น์ ๊ณผ ๋ฏธ์
์ด ๋ญ์ผ?
AI ํ๋ซํผ์ ๊ฐ๊ฒฉ ์ ์ฑ
์ ์๋ ค์ค
API ์ธ์ฆ ๋ฐฉ๋ฒ์ ์ค๋ช
ํด์ค
3. ๋น ๋ฅธ ๋ฌธ์ ํด๊ฒฐ
๋ฌธ์ | ํด๊ฒฐ ๋ฐฉ๋ฒ |
---|---|
์๋ฒ ์์ ์คํจ | npm install && npm run build |
๋ฌธ์ ๋ก๋ ์คํจ | docs/ ํด๋์ .md ํ์ผ ํ์ธ |
Claude Desktop ์ฐ๊ฒฐ ์คํจ | ์ค์ ํ์ผ ๊ฒฝ๋ก ํ์ธ ํ Claude Desktop ์ฌ์์ |
๐ ์ฑ๋ฅ ์ต์ ํ
BM25 ํ๋ผ๋ฏธํฐ ํ๋
- k1 ๊ฐ ์ฆ๊ฐ: ๋จ์ด ๋น๋์ ์ํฅ ์ฆ๊ฐ (1.2 โ 2.0)
- b ๊ฐ ์กฐ์ : ๋ฌธ์ ๊ธธ์ด ์ ๊ทํ ๊ฐ๋ (0.75 โ 0.5)
์ฒญํฌ ํฌ๊ธฐ ์ต์ ํ
- minWords ์ฆ๊ฐ: ๋ ํฐ ์ปจํ ์คํธ, ๋๋ฆฐ ๊ฒ์
- minWords ๊ฐ์: ์ ํํ ๋งค์นญ, ๋น ๋ฅธ ๊ฒ์
๐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
- ํ์ผ ๊ถํ: ๋ฌธ์ ๋๋ ํ ๋ฆฌ์ ์ ์ ํ ์ฝ๊ธฐ ๊ถํ ์ค์
- ํ๊ฒฝ ๋ณ์: ๋ฏผ๊ฐํ ์ค์ ์ ํ๊ฒฝ ๋ณ์๋ก ๊ด๋ฆฌ
- ๋คํธ์ํฌ: ํ์์ ๋ฐฉํ๋ฒฝ ๊ท์น ์ค์
๐ ํ๊ฒฝ ๋ณ์ ์ค์
export MCP_SERVER_NAME="my-knowledge-server"
export DOCS_BASE_PATH="./my-docs"
export BM25_K1="1.5"
export BM25_B="0.8"
export CHUNK_MIN_WORDS="50"
export LOG_LEVEL="debug"
๐ ๋ฌธ์ ํด๊ฒฐ
๋ฌธ์ ๋ฐ์ ์ ํ์ธ ์์:
- ๋ก๊ทธ ํ์ธ:
npm run dev
์ถ๋ ฅ ๋ฉ์์ง - ์ค์ ํ์ผ:
config.json
๋ฌธ๋ฒ ์ค๋ฅ ํ์ธ - ๋ฌธ์ ํด๋:
docs/
๋๋ ํ ๋ฆฌ์.md
ํ์ผ ํ์ธ - Claude Desktop: ์ค์ ํ์ผ ๊ฒฝ๋ก ๋ฐ ์ฌ์์
๐ก ํต์ฌ ์์ฝ
์ฆ์ ์ฌ์ฉ์ ์ํ ์ฒดํฌ๋ฆฌ์คํธ
์๋ ์ค์น ์ฌ์ฉ์:
-
./run.sh
(๋๋run.bat
) ์คํ - ์คํฌ๋ฆฝํธ๊ฐ ์ถ๋ ฅํ๋ Claude Desktop ์ค์ ๋ณต์ฌ
- Claude Desktop ์ฌ์์
- ํ ์คํธ ์ง๋ฌธ์ผ๋ก ์๋ ํ์ธ
์๋ ์ค์น ์ฌ์ฉ์:
-
npm install && npm run build && cp config.example.json config.json
-
docs/
ํด๋์ ๋งํฌ๋ค์ด ํ์ผ ์ถ๊ฐ - Claude Desktop ์ค์ ํ์ผ์ ํ๋ก์ ํธ ๊ฒฝ๋ก ์ง์
- Claude Desktop ์ฌ์์
- ํ ์คํธ ์ง๋ฌธ์ผ๋ก ์๋ ํ์ธ
์ฃผ์ ๋ช ๋ น์ด
- ๊ฐ๋ฐ:
npm run dev
- ๋น๋:
npm run build
- ์คํ:
npm start
- ํ
์คํธ:
npm test
MIT ๋ผ์ด์ ์ค | ๊ฐ๋ฐ ์ค์๋ npm run dev
์ฌ์ฉ ๊ถ์ฅ