@mastra/mcp 0.13.2 → 0.13.3-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 0.13.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Allows MCP server resources and prompts callbacks to access the "extra" MCP property, allowing to pass auth info and arbitrary data to the server. ([#8233](https://github.com/mastra-ai/mastra/pull/8233))
8
+
9
+ - Breaking change to move the agent.streamVNext/generateVNext implementation to the default stream/generate. The old stream/generate have now been moved to streamLegacy and generateLegacy ([#8097](https://github.com/mastra-ai/mastra/pull/8097))
10
+
11
+ - Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`d41aee5`](https://github.com/mastra-ai/mastra/commit/d41aee526d124e35f42720a08e64043229193679), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
12
+ - @mastra/core@0.20.0-alpha.0
13
+
3
14
  ## 0.13.2
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1721,13 +1721,13 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1721
1721
  const capturedResourceOptions = this.resourceOptions;
1722
1722
  if (!capturedResourceOptions) return;
1723
1723
  if (capturedResourceOptions.listResources) {
1724
- serverInstance.setRequestHandler(types_js.ListResourcesRequestSchema, async () => {
1724
+ serverInstance.setRequestHandler(types_js.ListResourcesRequestSchema, async (_request, extra) => {
1725
1725
  this.logger.debug("Handling ListResources request");
1726
1726
  if (this.definedResources) {
1727
1727
  return { resources: this.definedResources };
1728
1728
  } else {
1729
1729
  try {
1730
- const resources = await capturedResourceOptions.listResources();
1730
+ const resources = await capturedResourceOptions.listResources({ extra });
1731
1731
  this.definedResources = resources;
1732
1732
  this.logger.debug(`Fetched and cached ${this.definedResources.length} resources.`);
1733
1733
  return { resources: this.definedResources };
@@ -1739,12 +1739,12 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1739
1739
  });
1740
1740
  }
1741
1741
  if (capturedResourceOptions.getResourceContent) {
1742
- serverInstance.setRequestHandler(types_js.ReadResourceRequestSchema, async (request) => {
1742
+ serverInstance.setRequestHandler(types_js.ReadResourceRequestSchema, async (request, extra) => {
1743
1743
  const startTime = Date.now();
1744
1744
  const uri = request.params.uri;
1745
1745
  this.logger.debug(`Handling ReadResource request for URI: ${uri}`);
1746
1746
  if (!this.definedResources) {
1747
- const resources = await this.resourceOptions?.listResources?.();
1747
+ const resources = await this.resourceOptions?.listResources?.({ extra });
1748
1748
  if (!resources) throw new Error("Failed to load resources");
1749
1749
  this.definedResources = resources;
1750
1750
  }
@@ -1754,7 +1754,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1754
1754
  throw new Error(`Resource not found: ${uri}`);
1755
1755
  }
1756
1756
  try {
1757
- const resourcesOrResourceContent = await capturedResourceOptions.getResourceContent({ uri });
1757
+ const resourcesOrResourceContent = await capturedResourceOptions.getResourceContent({ uri, extra });
1758
1758
  const resourcesContent = Array.isArray(resourcesOrResourceContent) ? resourcesOrResourceContent : [resourcesOrResourceContent];
1759
1759
  const contents = resourcesContent.map((resourceContent) => {
1760
1760
  const contentItem = {
@@ -1782,13 +1782,13 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1782
1782
  });
1783
1783
  }
1784
1784
  if (capturedResourceOptions.resourceTemplates) {
1785
- serverInstance.setRequestHandler(types_js.ListResourceTemplatesRequestSchema, async () => {
1785
+ serverInstance.setRequestHandler(types_js.ListResourceTemplatesRequestSchema, async (_request, extra) => {
1786
1786
  this.logger.debug("Handling ListResourceTemplates request");
1787
1787
  if (this.definedResourceTemplates) {
1788
1788
  return { resourceTemplates: this.definedResourceTemplates };
1789
1789
  } else {
1790
1790
  try {
1791
- const templates = await capturedResourceOptions.resourceTemplates();
1791
+ const templates = await capturedResourceOptions.resourceTemplates({ extra });
1792
1792
  this.definedResourceTemplates = templates;
1793
1793
  this.logger.debug(`Fetched and cached ${this.definedResourceTemplates.length} resource templates.`);
1794
1794
  return { resourceTemplates: this.definedResourceTemplates };
@@ -1819,7 +1819,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1819
1819
  const capturedPromptOptions = this.promptOptions;
1820
1820
  if (!capturedPromptOptions) return;
1821
1821
  if (capturedPromptOptions.listPrompts) {
1822
- serverInstance.setRequestHandler(types_js.ListPromptsRequestSchema, async () => {
1822
+ serverInstance.setRequestHandler(types_js.ListPromptsRequestSchema, async (_request, extra) => {
1823
1823
  this.logger.debug("Handling ListPrompts request");
1824
1824
  if (this.definedPrompts) {
1825
1825
  return {
@@ -1827,7 +1827,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1827
1827
  };
1828
1828
  } else {
1829
1829
  try {
1830
- const prompts = await capturedPromptOptions.listPrompts();
1830
+ const prompts = await capturedPromptOptions.listPrompts({ extra });
1831
1831
  for (const prompt of prompts) {
1832
1832
  types_js.PromptSchema.parse(prompt);
1833
1833
  }
@@ -1848,11 +1848,11 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1848
1848
  if (capturedPromptOptions.getPromptMessages) {
1849
1849
  serverInstance.setRequestHandler(
1850
1850
  types_js.GetPromptRequestSchema,
1851
- async (request) => {
1851
+ async (request, extra) => {
1852
1852
  const startTime = Date.now();
1853
1853
  const { name, version, arguments: args } = request.params;
1854
1854
  if (!this.definedPrompts) {
1855
- const prompts = await this.promptOptions?.listPrompts?.();
1855
+ const prompts = await this.promptOptions?.listPrompts?.({ extra });
1856
1856
  if (!prompts) throw new Error("Failed to load prompts");
1857
1857
  this.definedPrompts = prompts;
1858
1858
  }
@@ -1873,7 +1873,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1873
1873
  try {
1874
1874
  let messages = [];
1875
1875
  if (capturedPromptOptions.getPromptMessages) {
1876
- messages = await capturedPromptOptions.getPromptMessages({ name, version, args });
1876
+ messages = await capturedPromptOptions.getPromptMessages({ name, version, args, extra });
1877
1877
  }
1878
1878
  const duration = Date.now() - startTime;
1879
1879
  this.logger.info(