-
Notifications
You must be signed in to change notification settings - Fork 0
Add logging #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logging #18
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds a configurable logging subsystem and integrates it into the client; updates README and examples with logging docs and log label changes; introduces logger-aware tests and a fetch mock utility; adjusts client internals (timeouts, health-cache TTLs) and exposes logger option in client options. Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f87c162 to
b91276c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/client.ts (1)
610-621: Update comments that say servers are “silently skipped”Now that
#getHealthyServerslogs warnings via#logger.warnwhen logging is enabled, the comments onagentTools/getAgentToolsthat say unhealthy servers are “silently skipped” are slightly out of date.You could tweak the wording to something like “skipped (with optional warnings when logging is enabled)” to stay in sync with the implementation, e.g.:
- * This method automatically filters out unhealthy servers by checking their health - * status before fetching tools. Unhealthy servers are silently skipped to ensure + * This method automatically filters out unhealthy servers by checking their health + * status before fetching tools. Unhealthy servers are skipped (with optional + * warnings when logging is enabled) to ensureThis makes it clear that the primary behaviour is skipping, with logging as an optional side effect.
Also applies to: 718-779
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (8)
README.md(1 hunks)examples/langchain/index.js(1 hunks)examples/vercel-ai/index.js(1 hunks)src/client.ts(4 hunks)src/logger.ts(1 hunks)src/types.ts(2 hunks)tests/unit/client.test.ts(2 hunks)tests/unit/utils/mockApi.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/types.ts (1)
src/logger.ts (1)
Logger(25-60)
tests/unit/client.test.ts (2)
tests/unit/utils/mockApi.ts (1)
createFetchMock(30-54)src/apiPaths.ts (1)
API_PATHS(10-44)
src/client.ts (2)
src/logger.ts (2)
Logger(25-60)createLogger(140-149)src/types.ts (1)
HealthStatusHelpers(20-34)
🪛 markdownlint-cli2 (0.18.1)
README.md
214-214: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (5)
examples/vercel-ai/index.js (1)
98-101: Consistent error label casingThe updated
[mcpd ERROR]prefix keeps the example aligned with the new logging conventions and has no behavioural impact. Looks good.examples/langchain/index.js (1)
106-110: Aligned error prefix with logging namingChanging the prefix to
[mcpd ERROR]matches the rest of the SDK’s messaging and is otherwise a no-op.src/types.ts (1)
5-6: Well-integrated logger option on McpdClientOptionsWiring the logger in as
logger?: Partial<Logger>with a type-only import is clean and keeps the public API aligned with the logging shim. The examples in the TSDoc accurately reflect the supported patterns (default logger, full custom logger, partial logger, and explicit no-op logger).Also applies to: 228-279
tests/unit/client.test.ts (1)
5-7: Good reuse of API_PATHS and shared fetch mockPulling in
API_PATHSand the sharedcreateFetchMockkeeps the logging tests in sync with the real client paths and avoids bespoke inline mocks. This should make the tests more robust to future path changes.src/client.ts (1)
46-47: Logger wiring into McpdClient looks soundImporting
createLoggerand storing a private#loggerthat’s initialised in the constructor withoptions.loggerkeeps logging concerns contained. Using it only inside#getHealthyServersto emit warnings for non-existent or unhealthy servers matches the tests and avoids touching the main request path. The default logger remaining env-driven (MCPD_LOG_LEVEL) is a good balance between observability and safety.Also applies to: 92-99, 115-142, 621-643
b91276c to
644779b
Compare
*Add logging * Update README * Add mock 'fetch' factory for the API * Tweak example log messages
644779b to
68e3de3
Compare
Add missing fields to mock Response objects: - Success case: status, statusText - Error case: statusText, text() This ensures the mock matches McpdClient expectations for non-2xx responses and prevents runtime errors when tests hit unmapped routes.
Remove unused consoleErrorSpy and use vi.stubGlobal() consistently:
- Remove consoleErrorSpy from beforeEach/afterEach (never asserted)
- Replace direct global.fetch assignments with vi.stubGlobal('fetch', ...)
- Aligns with outer suite's mocking pattern for easier test cleanup
* Remove serverCacheTtl from docs/comments as it was never implemented * Extract constants and defaults from magic numbers in constructor * Checked/updated all TSDocs in client.ts * Make a private agent tools function actually private * Type safety for log levels * Updated examples (deps, README)
06288b1 to
ac43be2
Compare
Adds configurable logging to the SDK.
Summary by CodeRabbit
New Features
Documentation
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.