MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / requestTaskStore

Function requestTaskStore

src/shared/protocol.ts:1572–1659  ·  view source on GitHub ↗
(request?: JSONRPCRequest, sessionId?: string)

Source from the content-addressed store, hash-verified

1570 }
1571
1572 private requestTaskStore(request?: JSONRPCRequest, sessionId?: string): RequestTaskStore {
1573 const taskStore = this._taskStore;
1574 if (!taskStore) {
1575 throw new Error('No task store configured');
1576 }
1577
1578 return {
1579 createTask: async taskParams => {
1580 if (!request) {
1581 throw new Error('No request provided');
1582 }
1583
1584 return await taskStore.createTask(
1585 taskParams,
1586 request.id,
1587 {
1588 method: request.method,
1589 params: request.params
1590 },
1591 sessionId
1592 );
1593 },
1594 getTask: async taskId => {
1595 const task = await taskStore.getTask(taskId, sessionId);
1596 if (!task) {
1597 throw new McpError(ErrorCode.InvalidParams, 'Failed to retrieve task: Task not found');
1598 }
1599
1600 return task;
1601 },
1602 storeTaskResult: async (taskId, status, result) => {
1603 await taskStore.storeTaskResult(taskId, status, result, sessionId);
1604
1605 // Get updated task state and send notification
1606 const task = await taskStore.getTask(taskId, sessionId);
1607 if (task) {
1608 const notification: TaskStatusNotification = TaskStatusNotificationSchema.parse({
1609 method: 'notifications/tasks/status',
1610 params: task
1611 });
1612 await this.notification(notification as SendNotificationT);
1613
1614 if (isTerminal(task.status)) {
1615 this._cleanupTaskProgressHandler(taskId);
1616 // Don't clear queue here - it will be cleared after delivery via tasks/result
1617 }
1618 }
1619 },
1620 getTaskResult: taskId => {
1621 return taskStore.getTaskResult(taskId, sessionId);
1622 },
1623 updateTaskStatus: async (taskId, status, statusMessage) => {
1624 // Check if task exists
1625 const task = await taskStore.getTask(taskId, sessionId);
1626 if (!task) {
1627 throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
1628 }
1629

Callers

nothing calls this directly

Calls 8

isTerminalFunction · 0.85
parseMethod · 0.80
createTaskMethod · 0.65
getTaskMethod · 0.65
storeTaskResultMethod · 0.65
getTaskResultMethod · 0.65
updateTaskStatusMethod · 0.65
listTasksMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…