mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 00:03:23 +02:00
[WIP] Refactor everything server to be more modular and use recommended APIs.
* Updated architecture.md
* Refactor/renamed resources/dynamic.ts to resources/template.ts
- refactor/renamed registerDynamicResources to registerResourceTemplates
- this highlights the more salient fact that we are demonstrating registration of resource templates in this example.
- exposed the ability to dynamically create the text resources from elsewhere (namely the resource-prompt example
* Added prompts/resource.ts
- in registerEmbeddedResourcePrompt()
- register a prompt that takes a resourceId and returns the prompt with the corresponding dynamically created resource embedded
This commit is contained in:
@@ -30,10 +30,11 @@ src/everything
|
||||
│ ├── index.ts
|
||||
│ ├── simple.ts
|
||||
│ ├── complex.ts
|
||||
│ └── completions.ts
|
||||
│ ├── completions.ts
|
||||
│ └── resource.ts
|
||||
├── resources
|
||||
│ ├── index.ts
|
||||
│ ├── dynamic.ts
|
||||
│ ├── template.ts
|
||||
│ └── static.ts
|
||||
├── docs
|
||||
│ ├── server-instructions.md
|
||||
@@ -87,16 +88,19 @@ At `src/everything`:
|
||||
- Registers `complex-prompt`: a prompt with two arguments (`city` required, `state` optional) used to compose a message.
|
||||
- completions.ts
|
||||
- Registers `completable-prompt`: a prompt whose arguments support server-driven completions using the SDK’s `completable(...)` helper (e.g., completing `department` and context-aware `name`).
|
||||
- resource.ts
|
||||
- Exposes `registerEmbeddedResourcePrompt(server)` which registers `resource-prompt` — a prompt that accepts `resourceId` and embeds a dynamically generated text resource within the returned messages. Internally reuses helpers from `resources/template.ts`.
|
||||
|
||||
- resources/
|
||||
|
||||
- index.ts
|
||||
- `registerResources(server)` orchestrator; delegates to static and dynamic resources.
|
||||
- dynamic.ts
|
||||
- `registerResources(server)` orchestrator; delegates to template‑based dynamic resources and static resources by calling `registerResourceTemplates(server)` and `registerStaticResources(server)`.
|
||||
- template.ts
|
||||
- Registers two dynamic, template‑driven resources using `ResourceTemplate`:
|
||||
- Text: `demo://resource/dynamic/text/{index}` (MIME: `text/plain`)
|
||||
- Blob: `demo://resource/dynamic/blob/{index}` (MIME: `application/octet-stream`, Base64 payload)
|
||||
- The `{index}` path variable must be a finite integer. Content is generated on demand with a GMT timestamp.
|
||||
- The `{index}` path variable must be a finite integer. Content is generated on demand with a timestamp.
|
||||
- Exposes helpers `textResource(uri, index)` and `textResourceUri(index)` so other modules can construct and embed text resources directly (e.g., from prompts).
|
||||
- static.ts
|
||||
- Registers static resources for each file in the `docs/` folder.
|
||||
- URIs follow the pattern: `demo://static/docs/<filename>`.
|
||||
@@ -157,6 +161,7 @@ At `src/everything`:
|
||||
- `simple-prompt` (prompts/simple.ts): No-argument prompt that returns a static user message.
|
||||
- `complex-prompt` (prompts/complex.ts): Two-argument prompt with `city` (required) and `state` (optional) used to compose a question.
|
||||
- `completable-prompt` (prompts/completions.ts): Demonstrates argument auto-completions with the SDK’s `completable` helper; `department` completions drive context-aware `name` suggestions.
|
||||
- `resource-prompt` (prompts/resource.ts): Accepts `resourceId` (string convertible to integer) and returns messages that include an embedded dynamic text resource generated via `resources/template.ts`.
|
||||
|
||||
- Resources
|
||||
- Dynamic Text: `demo://resource/dynamic/text/{index}` (content generated on the fly)
|
||||
|
||||
Reference in New Issue
Block a user