MCP Observer Server
mcp-observer-server
mcp-observer-server 파일 시스템 이벤트를 모니터링하고 MCP 클라이언트에 실시간 알림을 제공하는 MCP(Model Context Protocol) 서버입니다. 로컬 파일 시스템과 다음과 같은 AI 어시스턴트 간의 (양방향) 브리지 역할을 합니다. 클로드 검사기를 사용하면 파일 변경 사항에 자동으로 대응할 수 있습니다.
참고: 이 글은 제가 개발 중인 파일 모니터링 MCP 서버의 데모/POC입니다. 이와 관련된 많은 질문/의견/문제/토론이 올라오고 있어서, 제 접근 방식을 공유하고자 간단한 구현 예를 게시합니다.
문맥
MCP 프로토콜은 리소스 구독 개념을 정의합니다. 클라이언트는 리소스 변경 사항에 대한 알림을 요청할 수 있고, 서버는 알림을 보낼지 여부를 선택할 수 있습니다. 흐름도는 다음과 같습니다.

프로토콜에 따르면 클라이언트는 변경 사항을 읽기 위해 서버로 읽기 요청을 다시 보내야 합니다. (참고로 이 모든 것은 선택 사항입니다.) 하지만 저는 이 방식이 다소 번거롭고, 추가적인 작업이 필요하며, 리소스 업데이트 알림에 변경 사항도 함께 표시하는 것이 더 좋다고 생각합니다. 다행히 SDK는 meta / _meta 필드를 제공하여 원하는 대로 전송할 수 있습니다. 따라서 변경된 줄 수, 변경 사항의 차이점 등 무엇을 전송할지 알 수 없습니다. 이 데모에서는 구현하지 않았고, 지금은 타임스탬프만 전송하고 있습니다. (기본적으로 최소한의 POC를 제외한 모든 것을 서버에서 가져왔습니다.) 또한 stdio 전송 방식으로 실행되므로 특별한 내용은 없습니다.
참고!!! 아직 "실제" MCP 클라이언트에서 테스트해 보지 못했습니다. 제가 알기로는 대부분의 뷰 클라이언트가 리소스 구독을 지원하는 것으로 알고 있습니다. 어차피 선택 사항이니까요. 다행히 Inspector는 아주 좋은 클라이언트이므로 이 서버를 테스트하는 데 사용할 수 있습니다.
데모 지침:
저장소를 복제합니다.
uv(또는 다른 방법)를 사용하여 종속성을 설치합니다.make start(uv사용)를 사용하여 서버를 실행하거나npx @modelcontextprotocol/inspector uv run src/mcp_observer_server/server.py실행합니다.Inspector 클라이언트를 열고 stdio를 사용하여 연결합니다. 구성이 필요하지 않습니다.
subscribe도구를 사용하여 디렉토리나 파일을 모니터링합니다(또는 "리소스 목록"을 실행하고 리소스를 클릭한 다음 "구독" 버튼을 클릭하여 구독할 수도 있습니다).기본적으로 서버는
src/mcp_observer_server/watched.txt에watched.txt라는 파일을 노출합니다(파일은 .gitignored 형식이므로 직접 생성해야 합니다). 하지만 다른 파일도 구독할 수 있습니다.subscribe_default도구를 사용하여 이 파일을 구독할 수 있습니다.watched.txt파일(또는 구독한 파일)을 수정하면 Inspector 오른쪽 하단 패널에 서버 알림이 표시됩니다. 이것이 POC가 설정된 것입니다.
Related MCP server: File MCP Server
데모 시각화
서버를 시작하고 Inspector에 연결합니다.

기본 리소스를 나열하세요.

도구 나열:

기본 파일을 구독하세요:

파일을 수정하세요:

알림이 나타나는 것을 확인하세요:

🎉
서버 설명
MCP Observer 서버는 시스템의 파일 및 디렉터리 변경 사항을 추적하여 MCP 클라이언트가 이러한 이벤트를 구독하고 파일 생성, 수정, 삭제 또는 이동 시 조치를 취할 수 있도록 합니다(현재 데모에서는 수정 이벤트를 처리합니다). 이 서버는 전체 모델 컨텍스트 프로토콜(Model Context Protocol) 사양을 구현하여 다음을 제공합니다.
실시간 파일 모니터링 : 효율적인 파일 시스템 관찰을 위한 Watchdog 라이브러리 사용
구독 관리 : 모든 경로에 대한 모니터링 구독을 생성, 나열 및 취소합니다.
변경 내역 : 각 구독에 대한 최근 변경 사항 로그를 유지합니다(데모에서는 생략됨)
파일 및 디렉토리 액세스 : MCP 리소스를 통해 파일 내용 및 디렉토리 목록 읽기
상태 비저장 디자인 : 클라이언트가 파일 변경에 대한 응답으로 발생하는 일을 제어합니다.
주요 특징
특정 파일, 디렉토리 또는 전체 저장소의 변경 사항을 구독합니다.
파일 패턴 또는 이벤트 유형별로 이벤트 필터링(데모에서는 생략)
최근 변경 사항을 쿼리하여 어떤 파일이 영향을 받았는지 확인하세요(데모에서는 생략됨)
리소스 엔드포인트를 통해 파일 콘텐츠에 액세스
최소한의 종속성을 갖춘 가볍고 효율적인 구현
모든 MCP 호환 클라이언트(리소스 구독을 지원하는)와의 간단한 통합
실제 응용 프로그램
제가 해결하려는 가장 큰 문제는 클로드 코드(Claude Code)가 파일을 직접 수정하고 변경 사항을 직접 기록하지 않는 한, 저장소/프로젝트에서 무슨 일이 일어나고 있는지 전혀 알 수 없다는 것입니다. ("마지막으로 읽은 후 파일이 변경되었습니다"라는 알림 아시죠?) 프로젝트에서 실제로 진행 상황을 모니터링하는 클라이언트나 코딩 어시스턴트가 있으면, 모든 작업을 클로드에게 위임할 필요 없이, 단지 작업 진행 상황을 알 수 있다는 점이 매우 유용하다고 생각합니다. 몇 가지 실용적인 활용 사례는 다음과 같습니다.
자동 문서 업데이트 : 코드 변경 사항에 맞춰 문서를 동기화합니다. 코드를 업데이트하면 Claude에게 변경 사항이 알려지고, Claude는 문서 문자열 등을 사전에 확인하거나 업데이트합니다.
실시간 코드 검토 : 작업하는 동안 코드 변경 사항에 대한 실시간 피드백을 받고, 철자 오류, 유형 오류 등을 찾아내고 조언을 제공하는 진정한 쌍 프로그래밍입니다.
테스트 자동화 : 관련 파일이 수정되면 테스트를 실행합니다.
AI 지원 : AI 도구가 파일 변경 사항에 자동으로 대응할 수 있도록 합니다.
Git 커밋 자동화 : 커밋하는 것을 자주 잊어버리시나요? Claude가 변경 사항을 모니터링하고 커밋 작업을 더 자주 제안(또는 수행)해 드립니다.
현재 구현 설계
서버 구현은 단순성, 안정성, 유지 관리를 우선시하는 간소화된 아키텍처를 특징으로 합니다.
건축 하이라이트
단순화된 구조
집중된 구현(약 170줄의 코드)
핵심 구성요소의 작은 세트로 통합된 기능
MCP SDK를 직접 활용하는 깔끔한 기능 기반 디자인
높은 가독성과 유지관리성
효율적인 상태 관리
간단한 사전 구조는 클라이언트 세션에 대한 경로를 매핑합니다.
세션 경로 직접 매핑을 위해
watched사전을 사용합니다.명확한 데이터 흐름을 통한 최소한의 상태 추적
중복된 데이터 구조를 방지합니다
MCP 프로토콜 통합
MCP SDK 함수 데코레이터의 직접 사용
깨끗한 리소스 URI 처리
적절한 기능 구성을 통한 간소화된 서버 초기화
직접 알림 전달 시스템
이벤트 처리
간소화된 Watchdog 이벤트 핸들러 구현
이벤트-알림 직접 경로
call_soon_threadsafe통한 스레드 안전 통신효율적인 이벤트 필터링
알림 시스템
MCP 알림 기본 요소의 직접 사용
적절한 오류 처리를 통한 안정적인 전달
정확한 UTC 타임스탬프 처리
깔끔한 URI 포맷
핵심 구성 요소
데이터 구조
단일 글로벌 사전
watched맵 Path 객체는 ServerSession 객체 세트로 변환됩니다.각 경로 항목에는 해당 경로에 구독된 세션 세트가 포함되어 있습니다.
도구 API
두 가지 필수 도구:
subscribe및unsubscribe간단한 구독 관리를 위한 간단한 경로 매개변수
깔끔한 오류 처리 및 경로 검증
리소스 처리
리소스 목록을 통해 직접 노출되는 파일 URI
경로 확인 및 검증
파일의 텍스트 콘텐츠 읽기
이벤트 처리
Watcher 클래스는 FileSystemEventHandler를 확장합니다.
수정된 이벤트를 직접 처리합니다.
스레드 안전 알림 전송
중첩된 경로에 대한 경로 상대성 처리
알림 전달
ServerNotification 생성 및 전송
타임스탬프가 포함된 이벤트 메타데이터
깔끔한 URI 포맷
이 구현은 기능성과 단순성 사이에서 좋은 균형을 이루었으며, 그 결과 안정적이고 유지 관리가 쉬운 코드베이스가 만들어졌습니다.
Available Tools
4 toolslist_watchedA
List all currently monitored paths and their subscriber counts
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It indicates a read operation ('List') but doesn't specify whether this requires authentication, how data is returned (e.g., format, pagination), or any rate limits. The description is minimal and lacks essential behavioral context for a tool that likely interacts with subscription systems.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It directly communicates the tool's function in a clear and structured manner, making it easy to understand at a glance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (likely low, but involves subscription monitoring), no annotations, and no output schema, the description is insufficient. It doesn't explain what the output looks like (e.g., list format, data structure), potential errors, or operational constraints, leaving significant gaps for an AI agent to use it effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of inputs. The description doesn't need to compensate for any parameter gaps, and it appropriately doesn't mention parameters, making it complete in this regard. A baseline of 4 is appropriate for zero-parameter tools.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('List all') and resource ('currently monitored paths and their subscriber counts'), distinguishing it from sibling tools like subscribe/unsubscribe which perform different operations. It precisely defines what the tool does without being vague or tautological.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context by specifying 'currently monitored paths,' suggesting this tool is for viewing existing subscriptions rather than modifying them. However, it doesn't explicitly state when to use this versus alternatives or provide any exclusion criteria, leaving some ambiguity about its specific application scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
subscribeC
Subscribe to changes on a file or directory
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Subscribe to changes' implies a monitoring/notification function, it doesn't describe what kind of changes trigger notifications, how notifications are delivered, whether this requires specific permissions, rate limits, or what happens when multiple subscriptions exist. This leaves significant behavioral gaps for a tool that likely establishes ongoing monitoring.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a tool with one parameter and gets straight to the point with zero wasted verbiage.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a subscription tool with no annotations, no output schema, and minimal parameter documentation, the description is inadequate. It doesn't explain what 'subscribing' entails operationally, what format notifications take, how to manage subscriptions, or what the tool returns. Given the complexity of establishing monitoring and the complete lack of structured documentation, this description leaves too many questions unanswered.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage for the single 'path' parameter, the description provides no additional semantic information about what the path represents, its format, or constraints. The description mentions 'file or directory' which gives some context for the path parameter, but this is minimal compensation for the complete lack of schema documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Subscribe to changes') and target resource ('on a file or directory'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'subscribe_default', which appears to be a related subscription tool, so it doesn't fully differentiate from alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'subscribe_default' or 'list_watched'. It doesn't mention prerequisites, exclusions, or contextual factors that would help an agent choose between subscription-related tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
subscribe_defaultB
Subscribe to the default watched.txt file for development
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('subscribe') but doesn't explain what subscription entails (e.g., real-time updates, notifications, persistence), permissions required, side effects, or error conditions. This leaves significant gaps for a mutation-like operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with no wasted words. It front-loads the core action and target, making it easy to parse quickly. Every element ('subscribe', 'default', 'watched.txt file', 'development') contributes meaning without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has no parameters (simplifying input) but no annotations or output schema, the description is incomplete. It lacks details on behavior, return values, error handling, and differentiation from siblings like 'subscribe'. For a subscription tool with mutation implications, this leaves too many unknowns for effective agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters, and schema description coverage is 100% (empty schema). The description doesn't need to add parameter details, and it appropriately avoids discussing nonexistent inputs. A baseline of 4 is applied since no parameters exist to document.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('subscribe') and target resource ('default watched.txt file for development'), making the purpose understandable. It doesn't explicitly distinguish from sibling tools like 'subscribe' (which likely allows custom targets) or 'list_watched'/'unsubscribe', but the specificity of 'default' provides some implicit differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance is provided on when to use this tool versus alternatives like 'subscribe' (for non-default files) or 'list_watched' (for viewing subscriptions). The description implies it's for development purposes, but doesn't clarify prerequisites, exclusions, or specific use cases compared to siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
unsubscribeC
Unsubscribe from changes on a file or directory
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Unsubscribe from changes') but doesn't explain what 'changes' refers to, whether this operation is reversible, what permissions are required, or what happens after unsubscribing (e.g., notifications stop). For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a mutation operation with no annotations, no output schema, and low schema coverage), the description is incomplete. It lacks details on behavioral traits, parameter usage, output expectations, and differentiation from siblings, making it inadequate for informed tool selection and invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 1 parameter with 0% description coverage, so the schema provides no semantic information. The description mentions 'a file or directory' but doesn't clarify what the 'path' parameter represents (e.g., format, examples, or constraints). It adds minimal value beyond the schema's structural definition.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Unsubscribe from changes') and the target resource ('on a file or directory'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from its sibling 'subscribe' or 'subscribe_default', which would require mentioning what makes 'unsubscribe' different from those subscription tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'list_watched' or when not to use it. There's no mention of prerequisites (e.g., needing an existing subscription) or contextual cues for selection among sibling tools, leaving usage decisions ambiguous.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
- First observed
list_watched - First observed
subscribe - First observed
subscribe_default - First observed
unsubscribe
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose with no overlap: list_watched for viewing current subscriptions, subscribe for adding new ones, subscribe_default for a specific default case, and unsubscribe for removal. The descriptions reinforce these distinct roles, making misselection unlikely.
All tools follow a consistent verb_noun pattern (list_watched, subscribe, subscribe_default, unsubscribe) with clear, action-oriented names. The naming is uniform and predictable, enhancing usability.
With 4 tools, this server is well-scoped for its purpose of monitoring file/directory changes. Each tool serves a necessary function in the subscription lifecycle, and the count is neither too sparse nor bloated.
The tool set provides complete coverage for the domain of file/directory monitoring: list (read), subscribe (create), unsubscribe (delete), and a specialized subscribe_default for convenience. There are no obvious gaps, supporting full agent workflows.
Maintenance
Related MCP Connectors
Shared rooms for existing AI assistants, with messages, files and private memory vaults.
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
- ZapierOAuthcom.zapier
Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityFmaintenanceA Model Context Protocol server that provides AI agents with secure access to local filesystem operations, enabling reading, writing, and managing files through a standardized interface.10181 npm53Apache 2.0
- FlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server that enables AI assistants to perform comprehensive file operations including finding, reading, writing, editing, searching, moving, and copying files with security validations.71-
- AlicenseNot gradedqualityCmaintenanceA secure file server for AI assistants that provides comprehensive file operations and text manipulation with configurable access levels and multiple connection modes.6MIT
- FlicenseNot gradedqualityDmaintenanceA secure, sandboxed file system server that enables reading, writing, searching, and managing files through MCP-compatible AI clients with path traversal protection and size limits.-