Simplify streaming read open response

This commit is contained in:
Jeremy Rose
2026-06-09 17:15:02 -07:00
parent 5c8cfd4129
commit 2962e8f5d0
11 changed files with 17 additions and 61 deletions
+1 -1
View File
@@ -916,7 +916,7 @@
"type": "string"
},
"maxBytes": {
"description": "Requested upper bound. Values above `maxChunkBytes` are capped.",
"description": "Requested upper bound. Values above the server limit are capped.",
"format": "uint32",
"minimum": 0.0,
"type": [
@@ -9640,17 +9640,6 @@
"FsReadFileOpenResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Successful response for `fs/readFile/open`.",
"properties": {
"maxChunkBytes": {
"description": "Maximum decoded bytes returned by one read.",
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"maxChunkBytes"
],
"title": "FsReadFileOpenResponse",
"type": "object"
},
@@ -9681,7 +9670,7 @@
"type": "string"
},
"maxBytes": {
"description": "Requested upper bound. Values above `maxChunkBytes` are capped.",
"description": "Requested upper bound. Values above the server limit are capped.",
"format": "uint32",
"minimum": 0.0,
"type": [
@@ -5982,17 +5982,6 @@
"FsReadFileOpenResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Successful response for `fs/readFile/open`.",
"properties": {
"maxChunkBytes": {
"description": "Maximum decoded bytes returned by one read.",
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"maxChunkBytes"
],
"title": "FsReadFileOpenResponse",
"type": "object"
},
@@ -6023,7 +6012,7 @@
"type": "string"
},
"maxBytes": {
"description": "Requested upper bound. Values above `maxChunkBytes` are capped.",
"description": "Requested upper bound. Values above the server limit are capped.",
"format": "uint32",
"minimum": 0.0,
"type": [
@@ -1,17 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Successful response for `fs/readFile/open`.",
"properties": {
"maxChunkBytes": {
"description": "Maximum decoded bytes returned by one read.",
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"maxChunkBytes"
],
"title": "FsReadFileOpenResponse",
"type": "object"
}
@@ -6,7 +6,7 @@
"type": "string"
},
"maxBytes": {
"description": "Requested upper bound. Values above `maxChunkBytes` are capped.",
"description": "Requested upper bound. Values above the server limit are capped.",
"format": "uint32",
"minimum": 0.0,
"type": [
@@ -5,8 +5,4 @@
/**
* Successful response for `fs/readFile/open`.
*/
export type FsReadFileOpenResponse = {
/**
* Maximum decoded bytes returned by one read.
*/
maxChunkBytes: number, };
export type FsReadFileOpenResponse = Record<string, never>;
@@ -7,6 +7,6 @@
*/
export type FsReadFileReadParams = { handleId: string, offset: number,
/**
* Requested upper bound. Values above `maxChunkBytes` are capped.
* Requested upper bound. Values above the server limit are capped.
*/
maxBytes?: number | null, };
@@ -54,10 +54,7 @@ pub struct FsReadFileOpenParams {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct FsReadFileOpenResponse {
/// Maximum decoded bytes returned by one read.
pub max_chunk_bytes: u32,
}
pub struct FsReadFileOpenResponse {}
/// Read a bounded chunk from an open file at an absolute byte offset.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
@@ -67,7 +64,7 @@ pub struct FsReadFileReadParams {
pub handle_id: String,
#[ts(type = "number")]
pub offset: u64,
/// Requested upper bound. Values above `maxChunkBytes` are capped.
/// Requested upper bound. Values above the server limit are capped.
#[ts(optional = nullable)]
pub max_bytes: Option<u32>,
}
@@ -133,8 +133,7 @@ impl FsRequestProcessor {
connection_id: ConnectionId,
params: FsReadFileOpenParams,
) -> Result<FsReadFileOpenResponse, JSONRPCErrorError> {
let max_chunk_bytes = self
.handles(connection_id)
self.handles(connection_id)
.await
.open_read(
self.file_system()?,
@@ -144,10 +143,7 @@ impl FsRequestProcessor {
)
.await
.map_err(map_file_handle_error)?;
Ok(FsReadFileOpenResponse {
max_chunk_bytes: u32::try_from(max_chunk_bytes)
.map_err(|_| internal_error("file read chunk limit exceeds u32"))?,
})
Ok(FsReadFileOpenResponse {})
}
pub(crate) async fn read_file_read(
+1 -1
View File
@@ -421,7 +421,7 @@ async fn fs_streaming_read_supports_stat_and_positional_reads() -> Result<()> {
)
.await??,
)?;
assert!(open.max_chunk_bytes >= 4);
assert_eq!(open, FsReadFileOpenResponse {});
let wrong_type_id = mcp
.send_raw_request(
+6 -6
View File
@@ -30,15 +30,13 @@ Opens a file for positional reads.
Response:
```json
{
"maxChunkBytes": 262144
}
{}
```
### `fs/readFile/read`
Reads at most `maxBytes` starting at the absolute byte offset. If `maxBytes`
is omitted or exceeds `maxChunkBytes`, the server uses `maxChunkBytes`.
is omitted or exceeds the server's read limit, the server uses that limit.
```json
{
@@ -184,8 +182,10 @@ Response:
concurrently.
- Reads are positional and do not maintain a server-side cursor.
- Writes are sequential appends.
- Each read or write transfers at most `maxChunkBytes` decoded bytes.
- `maxChunkBytes` is currently 262144 bytes.
- Each read transfers at most the server's read limit.
- Each write transfers at most the `maxChunkBytes` returned by
`fs/writeFile/open`.
- Both limits are currently 262144 bytes.
- Backpressure comes from awaiting bounded read and write responses. Clients
should use a bounded pipeline of up to two read requests to hide transport
round-trip latency without accumulating unbounded response data.