Skip to content

Commit e606bd0

Browse files
chore(release): 0.14.0 and sync llms docs
Set Maven version to 0.14.0 and align llms.txt / llms-full.txt with README and implementation (YAML defaults, completions API, structured content). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d3f48a8 commit e606bd0

3 files changed

Lines changed: 145 additions & 51 deletions

File tree

llms-full.txt

Lines changed: 128 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ The Model Context Protocol (MCP) is a standardized protocol for building servers
4343
<dependency>
4444
<groupId>io.github.thought2code</groupId>
4545
<artifactId>mcp-annotated-java-sdk</artifactId>
46-
<version>0.13.0</version>
46+
<version>0.14.0</version>
4747
</dependency>
4848
```
4949

5050
### Gradle
5151

5252
```gradle
53-
implementation 'io.github.thought2code:mcp-annotated-java-sdk:0.13.0'
53+
implementation 'io.github.thought2code:mcp-annotated-java-sdk:0.14.0'
5454
```
5555

5656
## Quick Start Tutorial
@@ -65,6 +65,7 @@ mode: STDIO
6565
name: my-first-mcp-server
6666
version: 1.0.0
6767
type: SYNC
68+
instructions: You are a helpful AI assistant
6869
request-timeout: 20000
6970
capabilities:
7071
resource: true
@@ -152,10 +153,12 @@ public class MyPrompts {
152153
### Step 6: Run the Server
153154

154155
```bash
156+
# Compile your project
155157
./mvnw clean package
156-
java -jar target/your-app.jar
157158
```
158159

160+
Run `MyFirstMcpServer` from your IDE, or use `java -cp ...` with your compiled classes and dependencies on the classpath. Use an executable JAR setup in your own project if you need `java -jar` with a single file.
161+
159162
## Core Components
160163

161164
### Resources
@@ -167,9 +170,10 @@ Resource components are used to expose data to LLMs, similar to GET requests in
167170
| Parameter | Description | Required |
168171
|-----------|-------------|----------|
169172
| `uri` | Unique identifier of the resource (URI format) | Yes |
170-
| `description` | Resource description for LLM understanding | Yes |
173+
| `description` | Resource description for LLM understanding | No (defaults to `name`, then method name) |
171174
| `name` | Resource name (defaults to method name) | No |
172-
| `mimeType` | MIME type of the resource content | No |
175+
| `title` | Resource title (defaults to `name`) | No |
176+
| `mimeType` | MIME type of the resource content | No (default `text/plain`) |
173177

174178
### Tools
175179

@@ -179,7 +183,7 @@ Tool components are used to execute operations or calculations, similar to POST
179183

180184
| Parameter | Description | Required |
181185
|-----------|-------------|----------|
182-
| `description` | Tool description for LLM understanding | Yes |
186+
| `description` | Tool description for LLM understanding | No (defaults to tool `name`, then method name) |
183187
| `name` | Tool name (defaults to method name) | No |
184188
| `title` | Tool title for display purposes | No |
185189

@@ -188,8 +192,8 @@ Tool components are used to execute operations or calculations, similar to POST
188192
| Parameter | Description | Required |
189193
|-----------|-------------|----------|
190194
| `name` | Parameter name | Yes |
191-
| `description` | Parameter description | Yes |
192-
| `required` | Whether the parameter is required | No |
195+
| `description` | Parameter description | No (defaults to `name`) |
196+
| `required` | Whether the parameter is required | No (default `true`) |
193197

194198
### Prompts
195199

@@ -199,7 +203,7 @@ Prompt components are used to define reusable prompt templates.
199203

200204
| Parameter | Description | Required |
201205
|-----------|-------------|----------|
202-
| `description` | Prompt description for LLM understanding | Yes |
206+
| `description` | Prompt description for LLM understanding | No (defaults to prompt `name`, then method name) |
203207
| `name` | Prompt name (defaults to method name) | No |
204208
| `title` | Prompt title for display purposes | No |
205209

@@ -208,35 +212,74 @@ Prompt components are used to define reusable prompt templates.
208212
| Parameter | Description | Required |
209213
|-----------|-------------|----------|
210214
| `name` | Parameter name | Yes |
211-
| `description` | Parameter description | Yes |
212-
| `required` | Whether the parameter is required | No |
215+
| `description` | Parameter description | No (defaults to `name`) |
216+
| `required` | Whether the parameter is required | No (default `true`) |
213217

214218
### Completions
215219

216220
Completions provide auto-complete suggestions for resource URIs and prompt arguments.
217221

222+
Handlers must **return** `McpCompleteCompletion` and take **exactly one** parameter of type `McpSchema.CompleteRequest.CompleteArgument` (`name()` and `value()` identify the argument being completed).
223+
218224
#### Resource Completions
219225

220226
```java
227+
import com.github.thought2code.mcp.annotated.annotation.McpResourceCompletion;
228+
import com.github.thought2code.mcp.annotated.server.component.McpCompleteCompletion;
229+
import io.modelcontextprotocol.spec.McpSchema;
230+
import java.nio.file.Files;
231+
import java.nio.file.Path;
232+
import java.nio.file.Paths;
233+
import java.util.List;
234+
import java.util.stream.Collectors;
235+
221236
@McpResourceCompletion(uri = "file://")
222-
public List<String> completeFilePath(String uri, String cursorValue) {
223-
return Files.list(Paths.get(cursorValue))
224-
.map(Path::toString)
225-
.collect(Collectors.toList());
237+
public McpCompleteCompletion completeFileUri(McpSchema.CompleteRequest.CompleteArgument argument) {
238+
String prefix = argument.value() != null ? argument.value() : "";
239+
try {
240+
List<String> paths =
241+
Files.list(Paths.get(prefix.isEmpty() ? "." : prefix))
242+
.map(Path::toString)
243+
.limit(50)
244+
.collect(Collectors.toList());
245+
return McpCompleteCompletion.builder()
246+
.values(paths)
247+
.total(paths.size())
248+
.hasMore(false)
249+
.build();
250+
} catch (Exception e) {
251+
return McpCompleteCompletion.empty();
252+
}
226253
}
227254
```
228255

229256
#### Prompt Completions
230257

258+
`@McpPromptCompletion.name` must match the **registered prompt name** (by default, the Java method name of the `@McpPrompt` method). Filter by `argument.name()` when one prompt has multiple parameters.
259+
231260
```java
232-
@McpPromptCompletion(promptName = "generateCode", argumentName = "language")
233-
public List<String> completeLanguage(String value) {
234-
return Arrays.asList("Java", "Python", "JavaScript", "Go", "Rust");
261+
import com.github.thought2code.mcp.annotated.annotation.McpPromptCompletion;
262+
import com.github.thought2code.mcp.annotated.server.component.McpCompleteCompletion;
263+
import io.modelcontextprotocol.spec.McpSchema;
264+
import java.util.List;
265+
266+
@McpPromptCompletion(name = "generateCode")
267+
public McpCompleteCompletion completeGenerateCode(McpSchema.CompleteRequest.CompleteArgument argument) {
268+
if (!"language".equals(argument.name())) {
269+
return McpCompleteCompletion.empty();
270+
}
271+
return McpCompleteCompletion.builder()
272+
.values(List.of("Java", "Python", "JavaScript", "Go", "Rust"))
273+
.total(5)
274+
.hasMore(false)
275+
.build();
235276
}
236277
```
237278

238279
## Server Modes
239280

281+
If `mode` is omitted in `mcp-server.yml`, the server defaults to **STREAMABLE**.
282+
240283
| Mode | Description | Use Case |
241284
|------|-------------|----------|
242285
| **STDIO** | Standard input/output communication | CLI tools, local development |
@@ -256,7 +299,8 @@ mode: SSE
256299
sse:
257300
port: 8080
258301
endpoint: /sse
259-
messageEndpoint: /message
302+
message-endpoint: /mcp/message
303+
base-url: http://localhost:8080
260304
```
261305

262306
### STREAMABLE Mode
@@ -265,8 +309,8 @@ sse:
265309
mode: STREAMABLE
266310
streamable:
267311
mcp-endpoint: /mcp/message
268-
disallow-delete: true
269-
keep-alive-interval: 30000
312+
disallow-delete: false
313+
keep-alive-interval: 20000
270314
port: 8080
271315
```
272316

@@ -279,9 +323,24 @@ streamable:
279323
| `name` | Server name | `mcp-server` |
280324
| `version` | Server version | `1.0.0` |
281325
| `type` | Server type: `SYNC`, `ASYNC` | `SYNC` |
326+
| `instructions` | Instructions for the LLM client | (empty) |
282327
| `request-timeout` | Request timeout in milliseconds | `20000` |
283-
| `capabilities` | Enable resources, prompts, tools | all `true` |
284-
| `change-notification` | Enable change notifications | all `true` |
328+
| `capabilities.resource` | Enable resource support | `true` |
329+
| `capabilities.subscribe-resource` | Enable resource subscription | `true` |
330+
| `capabilities.prompt` | Enable prompt support | `true` |
331+
| `capabilities.tool` | Enable tool support | `true` |
332+
| `capabilities.completion` | Enable completion support | `true` |
333+
| `change-notification.resource` | Notify clients on resource change | `true` |
334+
| `change-notification.prompt` | Notify clients on prompt change | `true` |
335+
| `change-notification.tool` | Notify clients on tool change | `true` |
336+
| `sse.message-endpoint` | SSE POST message path | `/mcp/message` |
337+
| `sse.endpoint` | SSE stream path | `/sse` |
338+
| `sse.base-url` | Public base URL for the SSE server | *(empty)* |
339+
| `sse.port` | HTTP port for SSE mode | `8080` |
340+
| `streamable.mcp-endpoint` | Streamable HTTP MCP path | `/mcp/message` |
341+
| `streamable.disallow-delete` | Reject HTTP DELETE on session | `false` |
342+
| `streamable.keep-alive-interval` | Keep-alive interval (ms) | `20000` |
343+
| `streamable.port` | HTTP port for STREAMABLE mode | `8080` |
285344

286345
## Profile-based Configuration
287346

@@ -344,32 +403,48 @@ public int add(
344403

345404
## Structured Content
346405

347-
Tools can return structured content for rich responses:
406+
Tools can return structured content by returning a type that **implements** `McpStructuredContent` (often a `record` with `@McpJsonSchemaProperty` on fields). There is no `McpStructuredContent.of(...)` helper.
348407

349408
```java
409+
import com.github.thought2code.mcp.annotated.annotation.McpJsonSchemaDefinition;
410+
import com.github.thought2code.mcp.annotated.annotation.McpJsonSchemaProperty;
411+
import com.github.thought2code.mcp.annotated.annotation.McpTool;
412+
import com.github.thought2code.mcp.annotated.annotation.McpToolParam;
413+
import com.github.thought2code.mcp.annotated.server.McpStructuredContent;
414+
415+
@McpJsonSchemaDefinition
416+
public record User(
417+
@McpJsonSchemaProperty(description = "User id") String id,
418+
@McpJsonSchemaProperty(description = "Display name") String name)
419+
implements McpStructuredContent {
420+
421+
@Override
422+
public String asTextContent() {
423+
return "User " + id + ": " + name;
424+
}
425+
}
426+
350427
@McpTool(description = "Get user details")
351-
public McpStructuredContent<User> getUser(
352-
@McpToolParam(name = "id", description = "User ID") String id
353-
) {
354-
User user = userService.findById(id);
355-
return McpStructuredContent.of(user);
428+
public User getUser(@McpToolParam(name = "id", description = "User ID") String id) {
429+
return new User(id, "Ada");
356430
}
357431
```
358432

359433
## Error Handling
360434

361-
When a tool encounters an error, you can return an error result:
435+
If a tool method **throws any exception**, the server returns a `CallToolResult` with `isError` set to `true` and a generic method-invocation error message (the exception message is not forwarded to the client today).
436+
437+
For expected failures such as validation, return a normal value (for example a `String`) so the tool call remains a successful result with `isError` false:
362438

363439
```java
364440
@McpTool(description = "Divide two numbers")
365-
public Number divide(
441+
public String divide(
366442
@McpToolParam(name = "a", description = "Dividend") double a,
367-
@McpToolParam(name = "b", description = "Divisor") double b
368-
) {
369-
if (b == 0) {
370-
return McpStructuredContent.error("Division by zero is not allowed");
371-
}
372-
return a / b;
443+
@McpToolParam(name = "b", description = "Divisor") double b) {
444+
if (b == 0) {
445+
return "Cannot divide by zero.";
446+
}
447+
return Double.toString(a / b);
373448
}
374449
```
375450

@@ -413,25 +488,29 @@ your-mcp-project/
413488
│ └── example/
414489
│ └── McpServerTest.java # Unit tests
415490
└── target/
416-
└── your-app.jar # Executable JAR
491+
└── *.jar # Build output (name depends on your project)
417492
```
418493

419494
## Custom JSON Schema
420495

421-
For complex parameter types, you can define custom JSON schemas:
496+
For complex tool parameter or result types, annotate the type with `@McpJsonSchemaDefinition` and annotate fields (or record components) with `@McpJsonSchemaProperty` (JSON types are inferred from Java types).
422497

423498
```java
499+
import com.github.thought2code.mcp.annotated.annotation.McpJsonSchemaDefinition;
500+
import com.github.thought2code.mcp.annotated.annotation.McpJsonSchemaProperty;
501+
import com.github.thought2code.mcp.annotated.annotation.McpTool;
502+
import com.github.thought2code.mcp.annotated.annotation.McpToolParam;
503+
504+
@McpJsonSchemaDefinition
505+
public record CreateUserRequest(
506+
@McpJsonSchemaProperty(description = "User name") String name,
507+
@McpJsonSchemaProperty(description = "User age", required = false) int age,
508+
@McpJsonSchemaProperty(description = "Email address") String email) {}
509+
424510
@McpTool(description = "Create a user")
425-
@McpJsonSchemaDefinition(
426-
properties = {
427-
@McpJsonSchemaProperty(name = "name", type = "string", description = "User name"),
428-
@McpJsonSchemaProperty(name = "age", type = "integer", description = "User age"),
429-
@McpJsonSchemaProperty(name = "email", type = "string", description = "Email address")
430-
},
431-
required = {"name", "email"}
432-
)
433-
public User createUser(Map<String, Object> params) {
434-
return new User((String) params.get("name"), (String) params.get("email"));
511+
public String createUser(
512+
@McpToolParam(name = "user", description = "User payload") CreateUserRequest user) {
513+
return "Created: " + user.name();
435514
}
436515
```
437516

llms.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ A lightweight, annotation-based Java framework that simplifies MCP (Model Contex
2525
<dependency>
2626
<groupId>io.github.thought2code</groupId>
2727
<artifactId>mcp-annotated-java-sdk</artifactId>
28-
<version>0.13.0</version>
28+
<version>0.14.0</version>
2929
</dependency>
3030
```
3131

32+
### Gradle Dependency
33+
34+
```gradle
35+
implementation 'io.github.thought2code:mcp-annotated-java-sdk:0.14.0'
36+
```
37+
3238
### Create MCP Server
3339

3440
```java
@@ -85,10 +91,14 @@ public String generateCode(
8591
| `@McpResource` | Marks a method as an MCP resource |
8692
| `@McpPrompt` | Marks a method as an MCP prompt |
8793
| `@McpPromptParam` | Marks a parameter as a prompt parameter |
94+
| `@McpResourceCompletion` | Marks a method as a resource URI completion handler |
95+
| `@McpPromptCompletion` | Marks a method as a prompt-argument completion handler |
8896
| `@McpI18nEnabled` | Enables internationalization support |
8997

9098
## Server Modes
9199

100+
If `mode` is omitted in `mcp-server.yml`, the server defaults to **STREAMABLE**.
101+
92102
| Mode | Description | Use Case |
93103
|------|-------------|----------|
94104
| STDIO | Standard input/output | CLI tools, local development |
@@ -103,11 +113,16 @@ mode: STDIO
103113
name: my-mcp-server
104114
version: 1.0.0
105115
type: SYNC
116+
instructions: You are a helpful AI assistant
106117
request-timeout: 20000
107118
capabilities:
108119
resource: true
109120
prompt: true
110121
tool: true
122+
change-notification:
123+
resource: true
124+
prompt: true
125+
tool: true
111126
```
112127

113128
## Important Notes

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.thought2code</groupId>
88
<artifactId>mcp-annotated-java-sdk</artifactId>
9-
<version>0.14.0-SNAPSHOT</version>
9+
<version>0.14.0</version>
1010

1111
<name>MCP Annotated Java SDK</name>
1212
<description>Annotation-driven MCP (Model Context Protocol) Development with Java</description>

0 commit comments

Comments
 (0)