Skip to main content
Glama
Glean Chatbot

Glean Chatbot

Glean Chatbot

소규모 내부 계약 문서 세트를 Glean에 인덱싱하고, Search + Chat을 통해 해당 문서에서 질문에 답하며, 동일한 흐름을 MCP 도구(ask_glean)로 노출합니다.

요구 사항

  • Python 3.10+

  • Glean 인스턴스

  • Indexing API 토큰

  • Search 및 Chat 범위의 Client API 토큰

Related MCP server: search-context

설정

  1. 리포지토리를 클론하고 들어갑니다:

git clone <your-repo-url>
cd glean-chatbot
  1. 의존성을 설치합니다:

pip install -r requirements.txt
  1. 예제에서 .env 파일을 만들고 값을 입력합니다:

# macOS / Linux
cp .env.example .env

# Windows (PowerShell)
copy .env.example .env

Variable

Required

Purpose

GLEAN_INSTANCE

yes

인스턴스 이름 (https://<instance>-be.glean.com)

GLEAN_INDEXING_TOKEN

yes

Indexing API 토큰

GLEAN_CLIENT_TOKEN

yes

Client API 토큰 (Search + Chat)

GLEAN_ACT_AS

yes*

X-Glean-ActAs에 사용할 사용자 이메일 (*글로벌 클라이언트 토큰과 함께 필요)

GLEAN_DATASOURCE

no

데이터소스 이름 (기본값 interviewds)

GLEAN_DATASOURCE_DISPLAY

no

Glean UI에 표시되는 이름

GLEAN_URL_REGEX

no

모든 문서 viewURL이 일치해야 하는 정규식

.env는 config.py에 의해 (python-dotenv를 통해) 자동으로 로드됩니다. source할 필요는 없습니다.

실행

문서 인덱싱

python scripts/index_documents.py
# optional: wait until Search can find them
python scripts/index_documents.py --verify

CLI에서 질문

python scripts/ask.py "Who owns the Enronry Tony contract?"
python scripts/ask.py "What must OKLightning Tony deliver before go-live?" --top-k 3

MCP (Cursor)

프로젝트 구성은 .cursor/mcp.json에 있습니다(src/mcp_server.py의 절대 경로 + 환경 변수). 편집 후 Cursor를 다시 시작하거나 MCP를 리로드하세요. 도구 이름은 ask_glean입니다.

서버를 단독으로 스모크 테스트:

python src/mcp_server.py

테스트

python tests/test_pipeline.py

네트워크는 사용하지 않으며 Search/Chat을 모킹합니다.

작동 방식

scripts/index_documents.py는 data/documents.json을 Indexing API를 통해 푸시합니다. 쿼리 시점에는 src/pipeline.py가 Search를 호출한 다음, (히트가 있을 때만) 해당 히트를 폐쇄형 컨텍스트로 사용해 Chat을 호출하고 답변과 출처를 반환합니다. CLI와 MCP는 둘 다 동일한 파이프라인을 호출합니다. 결과는 자체 문서로 한정됩니다. Search 결과가 없으면 답변을 임의로 만들어 내는 대신 유사한 문서 제목을 제안합니다.

참고 사항 / 제한 사항

  • 공유 샌드박스는 datasourcesFilter를 무시합니다. 문서 ID 접두사(CUSTOM_<DATASOURCE>_Contract_)를 기준으로 클라이언트 측에서 필터링합니다.

  • 인덱싱은 비동기식입니다 — 문서가 검색 가능해지는 데 몇 분 정도 걸릴 수 있습니다.

  • 데모 문서는 allowAnonymousAccess: true를/를 사용합니다. 프로덕션에서는 그대로 배포하지 마세요.

  • 문서 viewURL은 GLEAN_URL_REGEX와 일치해야 합니다. 그렇지 않으면 인덱싱이 거부됩니다.

API 트레이드오프와 프로덕션 참고 사항은 DESIGN_NOTE.md를 참조하세요.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants and developer tools to securely access and interact with an organization's enterprise knowledge, documents, and people through natural language while respecting existing access permissions.
      166
      MIT
    • A
      license
      A
      quality
      F
      maintenance
      Enables semantic search across documentation stored in Gemini FileSearchStores, returning AI-generated answers with source citations.
      1
      1
      MIT