@agentailor/create-mcp-server 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +27 -3
  2. package/dist/assets/skills/tool-design/SKILL.md +107 -0
  3. package/dist/assets/skills/tool-design/references/examples.md +273 -0
  4. package/dist/assets/skills/tool-design/references/principles.md +261 -0
  5. package/dist/assets/skills/tool-design/references/testing.md +195 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/cli.js +4 -2
  8. package/dist/cli.test.js +19 -0
  9. package/dist/index.js +1 -0
  10. package/dist/interactive.js +8 -0
  11. package/dist/project-generator.d.ts +1 -0
  12. package/dist/project-generator.js +27 -4
  13. package/dist/skills.d.ts +43 -0
  14. package/dist/skills.js +64 -0
  15. package/dist/skills.test.d.ts +1 -0
  16. package/dist/skills.test.js +85 -0
  17. package/dist/templates/common/agents.md.d.ts +9 -0
  18. package/dist/templates/common/agents.md.js +221 -0
  19. package/dist/templates/common/agents.md.test.d.ts +1 -0
  20. package/dist/templates/common/agents.md.test.js +142 -0
  21. package/dist/templates/common/package.json.js +19 -8
  22. package/dist/templates/common/tsconfig.json.d.ts +3 -1
  23. package/dist/templates/common/tsconfig.json.js +8 -2
  24. package/dist/templates/fastmcp/index.js +5 -3
  25. package/dist/templates/fastmcp/readme.js +13 -0
  26. package/dist/templates/sdk/stateful/auth.js +5 -1
  27. package/dist/templates/sdk/stateful/auth.test.js +6 -2
  28. package/dist/templates/sdk/stateful/index.d.ts +6 -0
  29. package/dist/templates/sdk/stateful/index.js +7 -1
  30. package/dist/templates/sdk/stateful/readme.js +1 -1
  31. package/dist/templates/sdk/stateful/templates.test.js +6 -7
  32. package/dist/templates/sdk/stateless/index.d.ts +6 -0
  33. package/dist/templates/sdk/stateless/index.js +10 -1
  34. package/dist/templates/sdk/stateless/prompts.d.ts +1 -0
  35. package/dist/templates/sdk/stateless/prompts.js +32 -0
  36. package/dist/templates/sdk/stateless/readme.js +72 -13
  37. package/dist/templates/sdk/stateless/resources.d.ts +1 -0
  38. package/dist/templates/sdk/stateless/resources.js +49 -0
  39. package/dist/templates/sdk/stateless/server-test.d.ts +1 -0
  40. package/dist/templates/sdk/stateless/server-test.js +175 -0
  41. package/dist/templates/sdk/stateless/server.js +14 -68
  42. package/dist/templates/sdk/stateless/store-test.d.ts +1 -0
  43. package/dist/templates/sdk/stateless/store-test.js +38 -0
  44. package/dist/templates/sdk/stateless/store.d.ts +1 -0
  45. package/dist/templates/sdk/stateless/store.js +107 -0
  46. package/dist/templates/sdk/stateless/templates.test.js +160 -14
  47. package/dist/templates/sdk/stateless/tools.d.ts +1 -0
  48. package/dist/templates/sdk/stateless/tools.js +172 -0
  49. package/dist/templates/sdk/stdio/index.d.ts +6 -0
  50. package/dist/templates/sdk/stdio/index.js +6 -0
  51. package/dist/templates/sdk/stdio/readme.js +64 -11
  52. package/dist/templates/sdk/stdio/templates.test.js +11 -13
  53. package/package.json +2 -2
@@ -9,6 +9,7 @@ export function getReadmeTemplate(projectName, options) {
9
9
  inspectTools: 'npm run inspect:tools',
10
10
  inspectPrompts: 'npm run inspect:prompts',
11
11
  inspectResources: 'npm run inspect:resources',
12
+ test: 'npm test',
12
13
  },
13
14
  pnpm: {
14
15
  install: 'pnpm install',
@@ -18,6 +19,7 @@ export function getReadmeTemplate(projectName, options) {
18
19
  inspectTools: 'pnpm inspect:tools',
19
20
  inspectPrompts: 'pnpm inspect:prompts',
20
21
  inspectResources: 'pnpm inspect:resources',
22
+ test: 'pnpm test',
21
23
  },
22
24
  yarn: {
23
25
  install: 'yarn',
@@ -27,6 +29,7 @@ export function getReadmeTemplate(projectName, options) {
27
29
  inspectTools: 'yarn inspect:tools',
28
30
  inspectPrompts: 'yarn inspect:prompts',
29
31
  inspectResources: 'yarn inspect:resources',
32
+ test: 'yarn test',
30
33
  },
31
34
  }[packageManager];
32
35
  return `# ${projectName}
@@ -74,33 +77,67 @@ You can also call tools directly:
74
77
 
75
78
  \`\`\`bash
76
79
  # Call a tool
77
- npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/call --tool-name greet --tool-arg name=World
80
+ npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/call --tool-name create_note --tool-arg title="Ship v2" --tool-arg body="Draft the checklist"
78
81
  \`\`\`
79
82
 
80
83
  ## Included Examples
81
84
 
82
- This server comes with example implementations to help you get started:
85
+ A small notes server, included as a worked example of tools an agent can use
86
+ well. Notes are held in memory, so they last until the process restarts.
83
87
 
84
- ### Prompts
88
+ ### Tools
85
89
 
86
- - **greeting-template** - A simple greeting prompt that takes a name parameter
90
+ - **list_notes** - List notes, newest first, optionally filtered by tag.
91
+ - \`tag\` (optional): Only return notes carrying this tag
92
+ - \`limit\` (optional): Maximum to return, 1-100, defaults to 20
87
93
 
88
- ### Tools
94
+ Returns the page plus \`matched\`, \`returned\` and \`truncated\`, so a capped
95
+ result says so and suggests how to narrow it. An unknown tag is reported as
96
+ an error listing the tags that do exist, rather than as an empty list.
89
97
 
90
- - **greet** - Greets a user by name. Parameters:
91
- - \`name\`: Name of the person to greet
98
+ - **get_note** - Read one note in full by its id.
99
+ - \`id\`: Note id as returned by \`list_notes\` or \`create_note\`
100
+
101
+ - **create_note** - Save a note and return it, including its new id.
102
+ - \`title\`: Non-empty, at most 120 characters
103
+ - \`body\`: Plain text
104
+ - \`tags\` (optional): Tags used to filter in \`list_notes\`
92
105
 
93
106
  ### Resources
94
107
 
95
- - **greeting-resource** - A simple text resource at \`https://example.com/greetings/default\`
108
+ - **notes://{id}** - A single note as JSON. Listing the resource enumerates
109
+ the saved notes.
110
+
111
+ ### Prompts
112
+
113
+ - **summarize-notes** - Summarize the notes carrying a given tag
114
+
115
+ ## Tests
116
+
117
+ \`\`\`bash
118
+ ${commands.test}
119
+ \`\`\`
120
+
121
+ Two layers: \`src/notes-store.test.ts\` covers the data layer on its own, and
122
+ \`src/server.test.ts\` drives a real MCP client over an in-memory transport and
123
+ asserts on the payload a tool actually returns.
124
+
125
+ These are a worked example, not a quota. Each one pins something a tool's
126
+ description promises but nothing else checks - that a truncated list says so,
127
+ that an error names a next step, that an unknown filter is distinguishable from
128
+ an empty result. When you add a tool, one test in that spirit is enough.
96
129
 
97
130
  ## Project Structure
98
131
 
99
132
  \`\`\`
100
133
  ${projectName}/
101
134
  ├── src/
102
- │ ├── server.ts # MCP server definition (tools, prompts, resources)
103
- │ └── index.ts # stdio transport startup
135
+ │ ├── server.ts # Creates the McpServer and registers the primitives
136
+ │ ├── tools.ts # Tool definitions
137
+ │ ├── prompts.ts # Prompt definitions
138
+ │ ├── resources.ts # Resource definitions
139
+ │ ├── notes-store.ts # Example data layer, no MCP imports
140
+ │ └── index.ts # stdio transport startup
104
141
  ├── package.json
105
142
  ├── tsconfig.json
106
143
  └── README.md
@@ -108,9 +145,25 @@ ${projectName}/
108
145
 
109
146
  ## Customization
110
147
 
111
- - Add new tools, prompts, and resources in \`src/server.ts\`
148
+ - Add tools in \`src/tools.ts\`, prompts in \`src/prompts.ts\`, resources in
149
+ \`src/resources.ts\`. \`src/server.ts\` only wires them together.
150
+ - Replace the example's data layer in \`src/notes-store.ts\`. Keep it free of MCP
151
+ imports so it stays testable on its own.
112
152
  - Modify transport configuration in \`src/index.ts\`
113
153
 
154
+ ## Tool design skill
155
+
156
+ Agentailor's [tool-design](https://github.com/agentailor/skills) skill is
157
+ included at \`.agents/skills/tool-design/\`, so a coding agent working here has
158
+ the guidance on hand. Commit it so the whole team gets the same copy.
159
+
160
+ It is the version that shipped with the scaffolding CLI. To check for a newer
161
+ one — your call, not automatic:
162
+
163
+ \`\`\`bash
164
+ npx skills update -p -y
165
+ \`\`\`
166
+
114
167
  ## Learn More
115
168
 
116
169
  - [Model Context Protocol](https://modelcontextprotocol.io/)
@@ -12,20 +12,13 @@ describe('sdk/stdio templates', () => {
12
12
  expect(template).toContain("from '@modelcontextprotocol/server'");
13
13
  expect(template).not.toContain('@modelcontextprotocol/sdk');
14
14
  });
15
- it('should include example prompt', () => {
15
+ // The server is re-exported from stateless/, so this only checks that the
16
+ // same composition arrives here - its detail is tested in stateless/.
17
+ it('should compose the shared primitives', () => {
16
18
  const template = getServerTemplate(projectName);
17
- expect(template).toContain('greeting-template');
18
- expect(template).toContain('registerPrompt');
19
- });
20
- it('should include example tool', () => {
21
- const template = getServerTemplate(projectName);
22
- expect(template).toContain('greet');
23
- expect(template).toContain('registerTool');
24
- });
25
- it('should include example resource', () => {
26
- const template = getServerTemplate(projectName);
27
- expect(template).toContain('greeting-resource');
28
- expect(template).toContain('registerResource');
19
+ expect(template).toContain('registerTools(server)');
20
+ expect(template).toContain('registerPrompts(server)');
21
+ expect(template).toContain('registerResources(server)');
29
22
  });
30
23
  });
31
24
  describe('getIndexTemplate', () => {
@@ -55,6 +48,11 @@ describe('sdk/stdio templates', () => {
55
48
  expect(template).toContain("console.error('MCP Server running on stdio')");
56
49
  expect(template).not.toContain('console.log');
57
50
  });
51
+ // stdout is the protocol channel here - keep dotenv off this path entirely.
52
+ it('should not load dotenv', () => {
53
+ const template = getIndexTemplate();
54
+ expect(template).not.toContain('dotenv');
55
+ });
58
56
  });
59
57
  describe('getReadmeTemplate', () => {
60
58
  it('should include project name', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentailor/create-mcp-server",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Create a new MCP (Model Context Protocol) server project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "dist"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsc",
13
+ "build": "tsc && node scripts/copy-assets.mjs",
14
14
  "test": "vitest run",
15
15
  "test:watch": "vitest",
16
16
  "lint": "eslint src/",