-
Notifications
You must be signed in to change notification settings - Fork 97
Expose documentation pages as MCP resources instead of tool #542
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
Draft
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/expose-pages-as-resources
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8e79f4d
Initial plan
Copilot afa4805
Convert get_page_content tool to page resources using ResourceTemplate
Copilot 205996d
Add documentation explaining .js imports don't prevent type checking
Copilot 9843325
Remove typescript-js-imports.md documentation
Copilot fb6b097
Fix URL-encoded path handling in resource template callback
Copilot 01a5f53
Add debug logging to understand path encoding issue
Copilot 778d75b
Fix double slash issue by not adding slash if decoded path already ha…
Copilot 8ccb3af
Add test for URL-encoded path decoding and double-slash prevention
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # TypeScript Type Checking with .js Imports | ||
|
|
||
| ## Question: Does importing from `.js` modules prevent type checking? | ||
|
|
||
| **Answer: No, it does not prevent type checking.** | ||
|
|
||
| ## How It Works | ||
|
|
||
| When you import from a `.js` file in TypeScript: | ||
|
|
||
| ```typescript | ||
| import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js' | ||
| ``` | ||
|
|
||
| TypeScript automatically looks for and uses the corresponding `.d.ts` file (in this case, `mcp.d.ts`) for type information. This is a standard feature of TypeScript's module resolution. | ||
|
|
||
| ## Why Use .js Extensions in TypeScript? | ||
|
|
||
| With modern TypeScript and ESM (ECMAScript Modules): | ||
|
|
||
| 1. **Runtime Reality**: The `.js` extension refers to what will exist at runtime after compilation | ||
| 2. **ESM Specification**: The ESM specification requires explicit file extensions | ||
| 3. **Modern Module Resolution**: TypeScript's `"moduleResolution": "bundler"` handles this correctly | ||
|
|
||
| ## Verification | ||
|
|
||
| You can verify type checking works by: | ||
|
|
||
| 1. **Build Output**: The Next.js build shows "Running TypeScript ..." and catches type errors | ||
| 2. **IDE Support**: IntelliSense and autocomplete work correctly with these imports | ||
| 3. **Type Safety**: The code has full type checking, including: | ||
| - Function parameters | ||
| - Return types | ||
| - Object shapes | ||
| - Method signatures | ||
|
|
||
| ## Example in This Project | ||
|
|
||
| In `src/app/api/[transport]/route.ts`, the import: | ||
|
|
||
| ```typescript | ||
| import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js' | ||
| ``` | ||
|
|
||
| Provides full type checking for: | ||
|
|
||
| - The `ResourceTemplate` constructor parameters | ||
| - The `list` callback return type (must be `{ resources: Array<...> }`) | ||
| - The `registerResource` callback parameters and return type | ||
| - All method signatures on `ResourceTemplate` instances | ||
|
|
||
| ## Related Files | ||
|
|
||
| - Source: `node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js` | ||
| - Types: `node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.d.ts` | ||
|
|
||
| The `.d.ts` file contains all type definitions and is automatically used by TypeScript. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@copilot oos, remove
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.
Removed in commit 9843325