这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

Context

Cursor Context

1 - 代码库索引

索引代码库,以获得更准确的AI帮助和搜索结果

了解如何在Cursor中索引代码库,以获得更准确的AI帮助和搜索结果

索引代码库

为了获得更好和更准确的代码库答案,您可以索引您的代码库。在幕后,Cursor 为代码库中的每个文件计算嵌入,并将使用这些来提高代码库答案的准确性。

当项目被打开时,每个 Cursor 实例将初始化该工作空间的索引。初始索引设置完成后,Cursor 将自动为添加到您的工作区的任何新文件建立索引,以保持您的代码库上下文最新。

代码库索引的状态位于 Cursor Settings > Features > Codebase Indexing

高级设置

默认情况下,Cursor 将索引代码库中的所有文件。

您还可以展开 “Show Settings” 部分以访问更高级的选项。在这里,您可以决定是否要为新存储库启用自动索引,并配置 Cursor 在存储库索引期间将忽略的文件。

Cursor 使用与 VS Code 相同的包来处理文件忽略,这意味着它尊重所有 .gitignore 文件,包括子目录中的文件。您还可以为用户特定的忽略模式创建一个 .cursorignore 文件,您可能希望将其添加到 global.gitignore 中,以避免将其提交到存储库。

如果你的项目中有任何 AI 绝对不需要阅读的大型内容文件,忽略这些文件可以提高答案的准确性。

使用大型单体仓库

在处理包含数十万个文件的大型单体仓库时,重要的是要对索引的内容进行战略性的考虑。

  • 使用 .cursorignore 让每个开发人员配置他们在单体仓库中工作的文件夹和路径

  • 将 .cursorignore 添加到 global.gitignore

这允许每个开发人员在单体仓库中优化其特定工作区域的索引。

FAQ

我在哪里可以看到我索引的所有代码库?

目前,没有办法看到你索引的所有代码库的列表。您需要手动检查每个项目的索引状态,方法是在 Cursor 中打开项目并检查 Codebase Indexing settings。

如何删除所有代码库?

您可以从 “设置” 中删除 cursor 帐户以删除所有已索引的代码库,也可以从每个项目的“代码库索引”设置中手动删除单个代码库。目前没有办法在不删除帐户的情况下一次性删除所有代码库。

2 - AI规则

使用项目特定和全局规则在Cursor中自定义AI行为

使用 Cursor 中的规则,您可以控制底层模型的行为。您可以将其视为指令和/或LLMs的系统提示。

在 Cursor 内部,我们有两种主要方法来定制 AI 的行为以满足您的需求:

  • 项目规则:特定于项目的规则,存储在 .cursor/rules 目录中。当引用匹配的文件时,它们会自动包含在内。

  • 全局规则: 规则全局应用于所有项目,在 Cursor Settings > General > Rules 部分中进行配置。

在以下部分中了解有关如何使用它们的更多信息。

项目规则(推荐)

project-rules.png

项目规则提供了一个强大而灵活的系统,具有特定于路径的配置。项目规则存储在 .cursor/rules 目录中,并在项目的不同部分提供对 AI 行为的粒度控制。

它们是这样工作的

  • 语义描述:每个规则都可以包括一个关于何时应用它的描述
  • 文件模式匹配:使用 glob 模式指定规则适用于哪些文件/文件夹
  • 自动附加:引用匹配文件时可以自动包含规则
  • 以使用@file引用规则文件,允许您将多个规则链接在一起

您可以使用命令面板通过 ctrl + Shift + P > New Cursor Rule 创建新规则。通过使用项目规则,您还可以获得版本控制的好处,因为它只是一个文件

示例用例:

  • 针对某些文件类型的特定于框架的规则(例如,.tsx 文件的 SolidJS 首选项)
  • 自动生成文件的特殊处理(例如,.proto文件)
  • 自定义UI开发模式
  • 特定文件夹的代码样式和架构首选项 ​

全局规则

全局规则可以通过修改 Cursor Settings > General > Rules for AI 下的 AI 规则部分来添加。如果你想指定每个项目都应该包含的规则,比如输出语言、响应长度等,这很有用。

rules-for-ai.png

.cursorrules

为了向后兼容,您仍然可以在项目的根目录中使用 .cursorrules 文件。我们最终将在未来删除 .cursorrules,因此我们建议迁移到新的项目规则系统,以获得更好的灵活性和控制。

3 - @符号

用于上下文和命令的@符号

3.1 - 概述

Cursor 中用于上下文和命令的所有@符号概述

在 cursor 输入框中,例如 Composer、Chat 和 Cmd K中,您可以通过键入 @ 来使用 @符号。会弹出菜单显示建议列表,它将自动过滤,只显示根据您的输入最相关的建议。

Keyboard Shortcuts 键盘快捷键

您可以使用上/下箭头键浏览建议列表。您可以按 Enter 键选择建议。如果建议是一个类别,如 Files,建议将被过滤,只显示该类别中最相关的项目。

img

以下是所有可用的@符号列表:

3.2 - @Files

了解如何在 Cursor 的 Chat 和 Cmd+K 中使用 @ 来引用文件,以及预览和分块功能

在人工智能输入框中,如 Chat 和 Cmd K,您可以通过使用 @Files 引用整个文件。此外,如果您继续在 @ 之后键入,您将在 @Code 策略之后看到文件搜索结果。

为了确保您引用的文件是正确的文件,光标将显示文件路径的预览。当您在不同的文件夹中有多个同名文件时,这尤其有用。

实操:同名文件太多时体验很差,还是拖放吧

聊天长文件引用

在 Cursor 的聊天中,如果文件的内容太长,Cursor 会将文件分成更小的块,并根据与查询的相关性对其进行重新排序。

拖放

您可以将文件从主侧边栏拖放到 Composer、Chat 或 Cmd K 中,以将其添加为上下文。

实操:这个比较简单方便,尤其是同名文件很多时

3.3 - @Folders

将文件夹作为 Chat & cmd k 中的上下文,以增强 AI 对话

您可以在 Cursor 中引用整个文件夹作为上下文。当将 @Folders 与 Agent 一起使用时,它会附加目录中所有项目的列表,这允许 Agent 自己搜索内容。这使代理能够根据手头任务的需要独立地浏览和分析文件夹的内容。

实操:在 chat 窗口可以调出 files & folders:

cmd k 不行,只有 @files

3.4 - @Code

学习使用 @Code 符号和键盘快捷键引用代码,以便将代码添加到 chat 或编辑

要引用特定的代码段,可以使用 @Code 符号。

代码预览

与 @Files 符号类似,Cursor 将显示代码内容的预览,以便您可以验证所引用的代码是否正确。

实操:有不好代码

从编辑器

另一种添加代码片段作为上下文的方法是选择要引用的代码,然后单击 “添加到聊天”(Ctrl/Shift L)或“添加到编辑”(Ctrl/Shift K)。

这将把选定的代码段添加到聊天输入框或当前活动的 Cmd K 提示栏中。

实操:还是这个方便。

3.5 - @Docs

了解如何使用 @Docs 在 Cursor 中使用、添加和管理自定义文档作为上下文

Cursor 附带了一组第三方文档,这些文档被抓取、索引并准备用作上下文。您可以使用 @ 符号访问它们。你可以在这里找到我们默认的预抓取文档列表。

附录:默认的预抓取文档列表

备注:cursor 的默认的预抓取文档列表

https://raw.githubusercontent.com/getcursor/crawler/main/docs.jsonl

内容如下:

{  "name": "ASP.NET",  "crawlerStart": "https://learn.microsoft.com/en-us/aspnet/core/?view=aspnetcore-7.0",  "crawlerPrefix": "https://learn.microsoft.com/en-us/aspnet/core/"}
{  "name": "AWS Amplify",  "crawlerStart": "https://docs.amplify.aws/",  "crawlerPrefix": "https://docs.amplify.aws/"}
{  "name": "AWS CLI",  "crawlerStart": "https://docs.aws.amazon.com/cli/latest/reference/",  "crawlerPrefix": "https://docs.aws.amazon.com/cli/latest/reference/"}
{  "name": "AWS DynamoDB",  "crawlerStart": "https://docs.aws.amazon.com/dynamodb/",  "crawlerPrefix": "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/"}
{  "name": "AWS ECS",  "crawlerStart": "https://docs.aws.amazon.com/ecs/",  "crawlerPrefix": "https://docs.aws.amazon.com/ecs/latest/developerguide/"}
{  "name": "AWS Lambda",  "crawlerStart": "https://docs.aws.amazon.com/lambda/index.html",  "crawlerPrefix": "https://docs.aws.amazon.com/lambda/latest/dg/"}
{  "name": "AWS RDS",  "crawlerStart": "https://docs.aws.amazon.com/rds/",  "crawlerPrefix": "https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/"}
{  "name": "Amazon EC2",  "crawlerStart": "https://docs.aws.amazon.com/ec2/index.html",  "crawlerPrefix": "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/"}
{  "name": "Amazon S3",  "crawlerStart": "https://docs.aws.amazon.com/s3/index.html",  "crawlerPrefix": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/"}
{  "name": "Android SDK",  "crawlerStart": "https://developer.android.com/docs",  "crawlerPrefix": "https://developer.android.com/"}
{  "name": "Angular",  "crawlerStart": "https://angular.dev/overview",  "crawlerPrefix": "https://angular.dev/"}
{  "name": "Ansible",  "crawlerStart": "https://docs.ansible.com/ansible/latest/index.html",  "crawlerPrefix": "https://docs.ansible.com/ansible/latest/"}
{  "name": "Ant Design",  "crawlerStart": "https://ant.design/docs/react/introduce",  "crawlerPrefix": "https://ant.design/docs/react/"}
{  "name": "Apache Airflow",  "crawlerStart": "https://airflow.apache.org/docs/apache-airflow/stable/index.html",  "crawlerPrefix": "https://airflow.apache.org/docs/apache-airflow/stable/"}
{  "name": "Apollo GraphQL",  "crawlerStart": "https://www.apollographql.com/docs/",  "crawlerPrefix": "https://www.apollographql.com/docs/"}
{  "name": "Apple Developer Documention",  "crawlerStart": "https://developer.apple.com/documentation/",  "crawlerPrefix": "https://developer.apple.com/documentation/"}
{  "name": "Astro",  "crawlerStart": "https://docs.astro.build/en/",  "crawlerPrefix": "https://docs.astro.build/en/"}
{  "name": "Auth0",  "crawlerStart": "https://auth0.com/docs",  "crawlerPrefix": "https://auth0.com/docs"}
{  "name": "Azure Pipelines",  "crawlerStart": "https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops",  "crawlerPrefix": "https://docs.microsoft.com/en-us/azure/devops/pipelines/"}
{  "name": "Bash",  "crawlerStart": "https://www.gnu.org/software/bash/manual/bash.html",  "crawlerPrefix": "https://www.gnu.org/software/bash/manual/"}
{  "name": "BeautifulSoup",  "crawlerStart": "https://www.crummy.com/software/BeautifulSoup/bs4/doc/",  "crawlerPrefix": "https://www.crummy.com/software/BeautifulSoup/bs4/doc/"}
{  "name": "Boto3",  "crawlerStart": "https://boto3.amazonaws.com/v1/documentation/api/latest/index.html",  "crawlerPrefix": "https://boto3.amazonaws.com/v1/documentation/api/latest/"}
{  "name": "Bun",  "crawlerStart": "https://bun.sh/docs",  "crawlerPrefix": "https://bun.sh/docs"}
{  "name": "C#",  "crawlerStart": "https://learn.microsoft.com/en-us/dotnet/csharp/",  "crawlerPrefix": "https://learn.microsoft.com/en-us/dotnet/csharp/"}
{  "name": "CSS",  "crawlerStart": "https://developer.mozilla.org/en-US/docs/Web/CSS",  "crawlerPrefix": "https://developer.mozilla.org/en-US/docs/Web/CSS"}
{  "name": "Cheerio",  "crawlerStart": "https://cheerio.js.org/docs/intro",  "crawlerPrefix": "https://cheerio.js.org/docs/"}
{  "name": "CircleCI",  "crawlerStart": "https://circleci.com/docs/",  "crawlerPrefix": "https://circleci.com/docs/"}
{  "name": "Clerk",  "crawlerStart": "https://clerk.com/docs",  "crawlerPrefix": "https://clerk.com/docs"}
{  "name": "Cloudflare",  "crawlerStart": "https://developers.cloudflare.com/",  "crawlerPrefix": "https://developers.cloudflare.com/"}
{  "name": "CodeMirror",  "crawlerStart": "https://codemirror.net/docs/",  "crawlerPrefix": "https://codemirror.net/docs/"}
{  "name": "Cursor",  "crawlerStart": "https://docs.cursor.com/",  "crawlerPrefix": "https://docs.cursor.com/"}
{  "name": "Cypress",  "crawlerStart": "https://docs.cypress.io/guides/overview/why-cypress",  "crawlerPrefix": "https://docs.cypress.io/guides/"}
{  "name": "D3",  "crawlerStart": "https://d3js.org/getting-started",  "crawlerPrefix": "https://d3js.org/"}
{  "name": "Datadog",  "crawlerStart": "https://docs.datadoghq.com/",  "crawlerPrefix": "https://docs.datadoghq.com/"}
{  "name": "Deno",  "crawlerStart": "https://deno.land/manual@v1.35.0/introduction",  "crawlerPrefix": "https://deno.land/manual@v1.35.0/"}
{  "name": "DigitalOcean",  "crawlerStart": "https://docs.digitalocean.com/",  "crawlerPrefix": "https://docs.digitalocean.com/"}
{  "name": "Discord API",  "crawlerStart": "https://discord.com/developers/docs/intro",  "crawlerPrefix": "https://discord.com/developers/docs"}
{  "name": "Django",  "crawlerStart": "https://docs.djangoproject.com/en/4.2/",  "crawlerPrefix": "https://docs.djangoproject.com/en/4.2/"}
{  "name": "Django Rest Framework",  "crawlerStart": "https://www.django-rest-framework.org/api-guide/requests/",  "crawlerPrefix": "https://www.django-rest-framework.org/api-guide"}
{  "name": "Docker",  "crawlerStart": "https://docs.docker.com/",  "crawlerPrefix": "https://docs.docker.com/"}
{  "name": "Drizzle",  "crawlerStart": "https://orm.drizzle.team/docs/overview",  "crawlerPrefix": "https://orm.drizzle.team/docs/overview"}
{  "name": "ELK Stack",  "crawlerStart": "https://www.elastic.co/guide/en/elastic-stack/current/index.html",  "crawlerPrefix": "https://www.elastic.co/guide/en/elastic-stack/current/"}
{  "name": "ESBuild",  "crawlerStart": "https://esbuild.github.io/api/",  "crawlerPrefix": "https://esbuild.github.io/api/"}
{  "name": "ESLint",  "crawlerStart": "https://eslint.org/docs/latest/",  "crawlerPrefix": "https://eslint.org/docs/latest/"}
{  "name": "Elasticsearch",  "crawlerStart": "https://www.elastic.co/guide/en/enterprise-search/current/index.html",  "crawlerPrefix": "https://www.elastic.co/guide/en/enterprise-search/current/"}
{  "name": "Electron",  "crawlerStart": "https://www.electronjs.org/docs/latest/",  "crawlerPrefix": "https://www.electronjs.org/docs/latest/"}
{  "name": "Emacs",  "crawlerStart": "https://www.gnu.org/software/emacs/manual/html_node/emacs/",  "crawlerPrefix": "https://www.gnu.org/software/emacs/manual/html_node/emacs/"}
{  "name": "Expo",  "crawlerStart": "https://docs.expo.dev/",  "crawlerPrefix": "https://docs.expo.dev/"}
{  "name": "Express",  "crawlerStart": "https://expressjs.com/en/5x/api.html",  "crawlerPrefix": "https://expressjs.com/en/5x/"}
{  "name": "FFmpeg",  "crawlerStart": "https://ffmpeg.org/ffmpeg.html",  "crawlerPrefix": "https://ffmpeg.org/ffmpeg.html"}
{  "name": "Fabric.js",  "crawlerStart": "http://fabricjs.com/docs/",  "crawlerPrefix": "http://fabricjs.com/docs/"}
{  "name": "FastAPI",  "crawlerStart": "https://fastapi.tiangolo.com/tutorial/",  "crawlerPrefix": "https://fastapi.tiangolo.com/tutorial/"}
{  "name": "Firebase",  "crawlerStart": "https://firebase.google.com/docs",  "crawlerPrefix": "https://firebase.google.com/docs"}
{  "name": "Flask",  "crawlerStart": "https://flask.palletsprojects.com/en/2.3.x/",  "crawlerPrefix": "https://flask.palletsprojects.com/en/2.3.x/"}
{  "name": "Flutter",  "crawlerStart": "https://docs.flutter.dev/",  "crawlerPrefix": "https://docs.flutter.dev/"}
{  "name": "FontAwesome",  "crawlerStart": "https://fontawesome.com/docs/web/",  "crawlerPrefix": "https://fontawesome.com/docs/web/"}
{  "name": "GCP CLI",  "crawlerStart": "https://cloud.google.com/sdk/docs",  "crawlerPrefix": "https://cloud.google.com/sdk/docs"}
{  "name": "Git",  "crawlerStart": "https://git-scm.com/docs",  "crawlerPrefix": "https://git-scm.com/docs"}
{  "name": "GitHub Actions",  "crawlerStart": "https://docs.github.com/en/actions",  "crawlerPrefix": "https://docs.github.com/en/actions"}
{  "name": "GitLab CI",  "crawlerStart": "https://docs.gitlab.com/ee/ci/",  "crawlerPrefix": "https://docs.gitlab.com/ee/ci/"}
{  "name": "Go",  "crawlerStart": "https://go.dev/doc",  "crawlerPrefix": "https://go.dev/doc"}
{  "name": "Godot",  "crawlerStart": "https://docs.godotengine.org/en/stable/",  "crawlerPrefix": "https://docs.godotengine.org/en/stable/"}
{  "name": "Google Maps JS API",  "crawlerStart": "https://developers.google.com/maps/documentation/javascript",  "crawlerPrefix": "https://developers.google.com/maps/documentation/javascript"}
{  "name": "Gradle",  "crawlerStart": "https://docs.gradle.org/current/userguide/userguide.html",  "crawlerPrefix": "https://docs.gradle.org/current/userguide/"}
{  "name": "Grafana",  "crawlerStart": "https://grafana.com/docs/grafana/latest/",  "crawlerPrefix": "https://grafana.com/docs/grafana/latest/"}
{  "name": "GraphQL",  "crawlerStart": "https://graphql.org/learn/",  "crawlerPrefix": "https://graphql.org/learn/"}
{  "name": "HTML",  "crawlerStart": "https://developer.mozilla.org/en-US/docs/Web/HTML",  "crawlerPrefix": "https://developer.mozilla.org/en-US/docs/Web/HTML"}
{  "name": "Heroku",  "crawlerStart": "https://devcenter.heroku.com/categories/reference",  "crawlerPrefix": "https://devcenter.heroku.com/"}
{  "name": "Insomnia",  "crawlerStart": "https://docs.insomnia.rest/",  "crawlerPrefix": "https://docs.insomnia.rest/"}
{  "name": "Ionic",  "crawlerStart": "https://ionicframework.com/docs",  "crawlerPrefix": "https://ionicframework.com/docs"}
{  "name": "JAX",  "crawlerStart": "https://jax.readthedocs.io/en/latest/",  "crawlerPrefix": "https://jax.readthedocs.io/"}
{  "name": "JUnit 5",  "crawlerStart": "https://junit.org/junit5/docs/current/user-guide/",  "crawlerPrefix": "https://junit.org/junit5/docs/current/user-guide/"}
{  "name": "Java",  "crawlerStart": "https://docs.oracle.com/javase/8/docs/api/",  "crawlerPrefix": "https://docs.oracle.com/javase/8/docs/api/"}
{  "name": "Jenkins",  "crawlerStart": "https://www.jenkins.io/doc/",  "crawlerPrefix": "https://www.jenkins.io/doc/"}
{  "name": "Jest",  "crawlerStart": "https://jestjs.io/docs/getting-started",  "crawlerPrefix": "https://jestjs.io/docs/getting-started"}
{  "name": "Jquery",  "crawlerStart": "https://api.jqueryui.com/1.12/",  "crawlerPrefix": "https://api.jqueryui.com/1.12/"}
{  "name": "Keras",  "crawlerStart": "https://keras.io/api/",  "crawlerPrefix": "https://keras.io/api/"}
{  "name": "Kubernetes",  "crawlerStart": "https://kubernetes.io/docs/",  "crawlerPrefix": "https://kubernetes.io/docs/"}
{  "name": "LLVM",  "crawlerStart": "https://llvm.org/docs/",  "crawlerPrefix": "https://llvm.org/docs/"}
{  "name": "Langchain",  "crawlerStart": "https://python.langchain.com/docs/",  "crawlerPrefix": "https://python.langchain.com/docs/"}
{  "name": "Langchain-JS",  "crawlerStart": "https://js.langchain.com/docs/",  "crawlerPrefix": "https://js.langchain.com/docs/"}
{  "name": "Laravel",  "crawlerStart": "https://laravel.com/docs/10.x",  "crawlerPrefix": "https://laravel.com/docs/10.x"}
{  "name": "Linux Man Pages",  "crawlerStart": "https://man7.org/linux/man-pages/dir_all_alphabetic.html",  "crawlerPrefix": "https://man7.org/linux/man-pages/"}
{  "name": "MCP",  "crawlerStart": "https://modelcontextprotocol.io/introduction",  "crawlerPrefix": "https://modelcontextprotocol.io/"}
{  "name": "MLX",  "crawlerStart": "https://ml-explore.github.io/mlx/build/html/",  "crawlerPrefix": "https://ml-explore.github.io/mlx/build/html/"}
{  "name": "Material UI",  "crawlerStart": "https://mui.com/material-ui/getting-started/",  "crawlerPrefix": "https://mui.com/material-ui/"}
{  "name": "Matplotlib",  "crawlerStart": "https://matplotlib.org/stable/api/",  "crawlerPrefix": "https://matplotlib.org/stable/api/"}
{  "name": "Maven",  "crawlerStart": "https://maven.apache.org/guides/",  "crawlerPrefix": "https://maven.apache.org/guides/"}
{  "name": "Microsoft Teams",  "crawlerStart": "https://learn.microsoft.com/en-us/microsoftteams/platform/",  "crawlerPrefix": "https://learn.microsoft.com/en-us/microsoftteams/platform/"}
{  "name": "Mockito",  "crawlerStart": "https://javadoc.io/doc/org.mockito/mockito-core/latest/index.html",  "crawlerPrefix": "https://javadoc.io/doc/org.mockito/mockito-core/latest/"}
{  "name": "MongoDB",  "crawlerStart": "https://www.mongodb.com/docs/manual/",  "crawlerPrefix": "https://www.mongodb.com/docs/manual/"}
{  "name": "MySQL",  "crawlerStart": "https://dev.mysql.com/doc/",  "crawlerPrefix": "https://dev.mysql.com/doc/"}
{  "name": "NLTK",  "crawlerStart": "https://www.nltk.org/",  "crawlerPrefix": "https://www.nltk.org/"}
{  "name": "Neo4j",  "crawlerStart": "https://neo4j.com/docs/",  "crawlerPrefix": "https://neo4j.com/docs/"}
{  "name": "NestJS",  "crawlerStart": "https://docs.nestjs.com/",  "crawlerPrefix": "https://docs.nestjs.com/"}
{  "name": "Netlify",  "crawlerStart": "https://docs.netlify.com/",  "crawlerPrefix": "https://docs.netlify.com/"}
{  "name": "NextJS",  "crawlerStart": "https://nextjs.org/docs",  "crawlerPrefix": "https://nextjs.org/docs"}
{  "name": "Nginx",  "crawlerStart": "http://nginx.org/en/docs/",  "crawlerPrefix": "http://nginx.org/en/docs/"}
{  "name": "NodeJS",  "crawlerStart": "https://nodejs.org/api/",  "crawlerPrefix": "https://nodejs.org/api/"}
{  "name": "Notion",  "crawlerStart": "https://developers.notion.com/reference/",  "crawlerPrefix": "https://developers.notion.com/reference/"}
{  "name": "NumPy",  "crawlerStart": "https://numpy.org/doc/stable/",  "crawlerPrefix": "https://numpy.org/doc/stable/"}
{  "name": "Nuxt",  "crawlerStart": "https://nuxt.com/docs",  "crawlerPrefix": "https://nuxt.com/docs"}
{  "name": "OpenAI",  "crawlerStart": "https://platform.openai.com/docs/",  "crawlerPrefix": "https://platform.openai.com/docs/"}
{  "name": "OpenCV",  "crawlerStart": "https://docs.opencv.org/4.x/",  "crawlerPrefix": "https://docs.opencv.org/4.x/"}
{  "name": "PHP",  "crawlerStart": "https://www.php.net/manual/en/",  "crawlerPrefix": "https://www.php.net/manual/en/"}
{  "name": "Pandas",  "crawlerStart": "https://pandas.pydata.org/docs/",  "crawlerPrefix": "https://pandas.pydata.org/docs/"}
{  "name": "Playwright",  "crawlerStart": "https://playwright.dev/docs/intro",  "crawlerPrefix": "https://playwright.dev/docs/"}
{  "name": "Pnpm",  "crawlerStart": "https://pnpm.io/",  "crawlerPrefix": "https://pnpm.io/"}
{  "name": "PostgreSQL",  "crawlerStart": "https://www.postgresql.org/docs/current/",  "crawlerPrefix": "https://www.postgresql.org/docs/current/"}
{  "name": "Postman",  "crawlerStart": "https://learning.postman.com/docs/",  "crawlerPrefix": "https://learning.postman.com/docs/"}
{  "name": "Prisma",  "crawlerStart": "https://www.prisma.io/docs",  "crawlerPrefix": "https://www.prisma.io/docs"}
{  "name": "Puppeteer",  "crawlerStart": "https://pptr.dev/",  "crawlerPrefix": "https://pptr.dev/"}
{  "name": "PyTorch",  "crawlerStart": "https://pytorch.org/docs/stable/",  "crawlerPrefix": "https://pytorch.org/docs/stable/"}
{  "name": "Python",  "crawlerStart": "https://docs.python.org/3/",  "crawlerPrefix": "https://docs.python.org/3/"}
{  "name": "ROS",  "crawlerStart": "https://docs.ros.org/en/rolling/",  "crawlerPrefix": "https://docs.ros.org/en/rolling/"}
{  "name": "Railway",  "crawlerStart": "https://docs.railway.app/",  "crawlerPrefix": "https://docs.railway.app/"}
{  "name": "React",  "crawlerStart": "https://react.dev/reference/react",  "crawlerPrefix": "https://react.dev/reference/"}
{  "name": "Redis",  "crawlerStart": "https://redis.io/docs/",  "crawlerPrefix": "https://redis.io/docs/"}
{  "name": "Regex",  "crawlerStart": "https://www.regular-expressions.info/",  "crawlerPrefix": "https://www.regular-expressions.info/"}
{  "name": "Remix",  "crawlerStart": "https://remix.run/docs/en/main",  "crawlerPrefix": "https://remix.run/docs/"}
{  "name": "Ruby",  "crawlerStart": "https://docs.ruby-lang.org/en/master/",  "crawlerPrefix": "https://docs.ruby-lang.org/en/"}
{  "name": "Rust",  "crawlerStart": "https://doc.rust-lang.org/book/",  "crawlerPrefix": "https://doc.rust-lang.org/book/"}
{  "name": "Rust Stdlib",  "crawlerStart": "https://doc.rust-lang.org/std/",  "crawlerPrefix": "https://doc.rust-lang.org/std/"}
{  "name": "SQLite",  "crawlerStart": "https://www.sqlite.org/docs.html",  "crawlerPrefix": "https://www.sqlite.org/"}
{  "name": "Scikit-learn",  "crawlerStart": "https://scikit-learn.org/stable/",  "crawlerPrefix": "https://scikit-learn.org/stable/"}
{  "name": "Selenium",  "crawlerStart": "https://www.selenium.dev/documentation/",  "crawlerPrefix": "https://www.selenium.dev/documentation/"}
{  "name": "Sentry",  "crawlerStart": "https://docs.sentry.io/",  "crawlerPrefix": "https://docs.sentry.io/"}
{  "name": "Socket.io",  "crawlerStart": "https://socket.io/docs/v4/",  "crawlerPrefix": "https://socket.io/docs/v4/"}
{  "name": "Solidity",  "crawlerStart": "https://docs.soliditylang.org/en/latest/",  "crawlerPrefix": "https://docs.soliditylang.org/en/latest/"}
{  "name": "Spring",  "crawlerStart": "https://docs.spring.io/spring-framework/reference/",  "crawlerPrefix": "https://docs.spring.io/spring-framework/reference/"}
{  "name": "Stripe",  "crawlerStart": "https://stripe.com/docs",  "crawlerPrefix": "https://stripe.com/docs"}
{  "name": "Supabase",  "crawlerStart": "https://supabase.com/docs",  "crawlerPrefix": "https://supabase.com/docs"}
{  "name": "Svelte",  "crawlerStart": "https://svelte.dev/docs",  "crawlerPrefix": "https://svelte.dev/docs"}
{  "name": "Tailwind",  "crawlerStart": "https://tailwindcss.com/docs",  "crawlerPrefix": "https://tailwindcss.com/docs"}
{  "name": "Terraform",  "crawlerStart": "https://developer.hashicorp.com/terraform/docs",  "crawlerPrefix": "https://developer.hashicorp.com/terraform/docs"}
{  "name": "Three.js",  "crawlerStart": "https://threejs.org/docs/",  "crawlerPrefix": "https://threejs.org/docs/"}
{  "name": "Tinygrad",  "crawlerStart": "https://docs.tinygrad.org",  "crawlerPrefix": "https://docs.tinygrad.org"}
{  "name": "TypeScript",  "crawlerStart": "https://www.typescriptlang.org/docs/",  "crawlerPrefix": "https://www.typescriptlang.org/docs/"}
{  "name": "Unity",  "crawlerStart": "https://docs.unity3d.com/Manual/",  "crawlerPrefix": "https://docs.unity3d.com/Manual/"}
{  "name": "Unreal Engine",  "crawlerStart": "https://docs.unrealengine.com/5.0/en-US/",  "crawlerPrefix": "https://docs.unrealengine.com/5.0/en-US/"}
{  "name": "Vercel",  "crawlerStart": "https://vercel.com/docs",  "crawlerPrefix": "https://vercel.com/docs"}
{  "name": "Vim",  "crawlerStart": "https://vimhelp.org/",  "crawlerPrefix": "https://vimhelp.org/"}
{  "name": "Vite",  "crawlerStart": "https://vitejs.dev/guide/",  "crawlerPrefix": "https://vitejs.dev/guide/"}
{  "name": "Vitest",  "crawlerStart": "https://vitest.dev/guide/",  "crawlerPrefix": "https://vitest.dev/guide/"}
{  "name": "Vue",  "crawlerStart": "https://vuejs.org/guide/introduction.html",  "crawlerPrefix": "https://vuejs.org/guide/"}
{  "name": "Webpack",  "crawlerStart": "https://webpack.js.org/concepts/",  "crawlerPrefix": "https://webpack.js.org/concepts/"}
{  "name": "Zsh",  "crawlerStart": "https://zsh.sourceforge.io/Doc/",  "crawlerPrefix": "https://zsh.sourceforge.io/Doc/"}
{  "name": "help",  "crawlerStart": "https://docs.cursor.com/get-started/welcome",  "crawlerPrefix": "https://docs.cursor.com/"}

140 多个常用的文档。

添加自定义文档

如果您想抓取和索引尚未提供的自定义文档,您可以通过 @Docs > Add new doc 来完成。

实操:调出菜单

在您粘贴所需文档的 URL 后,

将出现以下模式:

实操: confirm 之后会报错,因为 entrypoint 强制要求是一个以文件介绍的 url,而不是 https://www.docsy.dev/docs/ 这种目录形式的 url。

在路径后面加入 index.html 之后,就可以正常抓取了。

https://www.docsy.dev/docs/index.html

然后 Cursor 将索引并学习文档,您将能够像任何其他文档一样将其用作上下文。

如果要索引所有子页面和子目录,请确保在 URL 后面添加一个斜杠

实操:能看到索引的具体的页面

实操:通过 @Docs 调出

管理自定义缓存

在 Cursor Settings > Features > Docs 下,您将看到您添加的文档。您可以在此处编辑、删除或添加新文档。

3.6 - @Git

了解如何在 Cursor 的 Chat 中使用 @Git 分析差异、查找 bug 并生成提交消息

目前,@Git 仅在 Chat & Composer 中支持

在 Cursor 的 Chat 中,您可以使用 @Git 将 git commits、diffs 或 pull requests 添加到提示词中。

常见用例

@Git 的一个常见用例是允许 Cursor 的 AI 扫描差异并查找可能由差异引起的错误或问题。

您还可以使用 @Diff of Working State 从当前的差异生成提交消息。

实操: 生成的 commit message 还是很不错的,可以参考。

咨询 ai 得到的用法

我来为您解释 Cursor 中 @Git 的使用方法:

根据文档内容,@Git 是 Cursor 中一个强大的功能,目前仅在 Chat 和 Composer 中可用。以下是主要用途:

  1. 代码差异分析

    • 您可以使用 @Git 来分析代码的变更(diffs)
    • AI 可以帮助扫描这些变更,找出潜在的问题或 bug
  2. 提交消息生成

    • 使用 @Diff of Working State 命令可以基于当前的代码变更自动生成 git commit 消息
  3. 代码审查

    • 可以将 git commits、diffs 或 pull requests 添加到对话中
    • AI 可以帮助分析这些变更的影响

使用步骤:

  1. 在 Cursor 的 Chat 界面中
  2. 输入 @Git 或相关命令
  3. 选择您想要分析的内容(比如某个 commit 或当前的代码变更)

这个功能特别适合:

  • 代码审查时快速发现潜在问题
  • 自动生成规范的提交信息
  • 分析代码变更的影响范围

需要注意的是,目前这个功能仅限于 Chat 和 Composer 环境中使用。

如果您想了解更多具体的使用场景或详细信息,建议您尝试在 Cursor 中实际操作一下这些功能。

3.7 - @Web

@Web 命令自动搜索互联网,以查找 cursor 查询的相关上下文

@Web

使用 @Web,Cursor 根据查询和您提供的上下文构造搜索查询,并搜索 Web 以查找相关信息作为附加上下文。

这可能有助于 Cursor 在线查找最新信息,或者允许 Cursor 在几秒钟内抓取多个网站以找到最佳答案,而无需用户手动搜索任何地方。

实操:咨询明天的上海天气,给了最新的信息(2025-03-28号的天气信息),列出了三个网站。但很奇怪,答复中的明天写的是 2025-03-05,给的三个URL显示的28号的天气。

当使用 agent 模式时,Cursor 将在需要最新信息或其他上下文时自动搜索 Web。

3.8 - @Definitions

使用 @Definitions 符号将附近的代码定义添加到 Cmd K 上下文

此功能目前仅适用于 Cmd K。

@Definitions 符号将所有附近的定义作为上下文添加到 Cmd K。

3.9 - @Link

通过链接到外部网站和资源,将 Web 内容用作上下文

粘贴链接

为了让 cursor 在粘贴链接之前访问一个链接,你会看到这个链接是“标记”的。

实操:复制了一个链接 https://www.docsy.dev/docs/adding-content/shortcodes/ 到 chat 中,可以看到链接前面加了一个 @,我让它总结一下:

删除链接

默认情况下,我们会自动解析链接并将其转换为聊天中的 @Links 。如果您希望链接为纯文本,请单击链接,然后单击 “取消链接 ”。

实操:单击一下链接就有取消链接的 unlink 按钮了

您也可以不带格式地粘贴以确保链接未被标记。

实操:windows下是 control + Shift + v 无格式粘贴

3.10 - @Lint Errors

访问和引用代码库中的 linting 错误

@Lint Errors 符号自动捕获并提供有关当前活动文件中的任何 lint 错误和警告的上下文。

默认情况下 ,Composer 和 Agent 可以看到 lint 错误:

咨询 cursor 给出的答复

让我帮您了解关于 @Lint Errors 的更多信息。我会先搜索相关代码来了解更多细节。

根据搜索结果,我来为您详细解释 Cursor 中的 @Lint Errors 功能:

@Lint Errors 是 Cursor 中的一个重要功能,主要用于:

  1. 基本功能

    • 自动捕获并提供当前活动文件中的任何 lint 错误和警告的上下文
    • 默认情况下,Composer 和 Agent 模式可以看到 lint 错误
  2. 智能修复

    • Cursor 让 AI 可以直接访问代码库中的 linter
    • 当检测到已安装的 Linter 标记的问题时,AI 可以智能地尝试自行修复这些问题
    • 这意味着您将始终获得干净、兼容的代码,而无需手动检查和修复任何问题
  3. 使用场景

    • 在编写代码时自动检测和修复代码规范问题
    • 在代码审查时快速发现潜在问题
    • 确保代码质量和一致性
  4. 注意事项

    • 某些语言(如 Rust)要求在 lint 错误出现之前保存文件,这可能会限制此功能在所有语言中的有效性
    • 该功能主要在 Chat 和 Composer 环境中使用
  5. 与其他功能的集成

    • 与 Tab 功能集成:Tab 可以根据您最近的更改和 linter 错误提出建议
    • 与 Agent 模式集成:Agent 可以自动检测和修复 lint 错误

这个功能是 Cursor 中代码质量控制的重要组成部分,可以帮助开发者保持代码质量,减少手动检查的工作量。

3.11 - @Recent Changes

访问和引用工作区中的最新更改

cursor 会自动跟踪最近对代码库所做的更改。@Recent Changes 符号允许您将这些修改作为上下文传递。

实操:让 cursor 总结一下最近对代码库所做的更改。

3.12 - @Cursor Rules

在项目中使用和引用 cursor 规则

@Cursor Rules 符号提供对您为项目设置的项目规则和指导方针的访问,允许您将它们显式应用到上下文。

实操:需要先创建规则

3.13 - @Notepads

在 cursor 中引用并包含记事本作为上下文

@Notepads 符号允许您在对话中引用和包含您的 Notepads 作为上下文。记事本是功能强大的上下文共享工具,可以在编写器和聊天交互之间架起差距的桥梁,允许您为开发工作流创建可重用的上下文。

实操:TODO

3.14 - @Summarized Composers

在新的对话中引用以前 Composer 会话的摘要版本作为上下文

在 Composer 中处理复杂任务时,您可能希望引用上下文或以前对话中的决策。@Summarized Composers 符号允许您将以前 Composer 会话的摘要版本作为上下文包含在内。

这在以下情况下特别有用:

  • 您有一个很长的 Composer 会话,其中包含要引用的重要上下文
  • 你开始了一项新的但相关的任务,并希望保持连续性
  • 你想分享上一次会议的推理或决定

cursor 的解释

根据文件内容,我来为您解释 @-summarized-composers 符号的功能:

@-summarized-composers 是一个用于在 Cursor IDE 中引用历史 Composer 会话摘要的特殊符号。它的主要用途包括:

  1. 上下文引用:允许您在新的对话中引用之前 Composer 会话的摘要版本作为上下文。

  2. 使用场景

    • 当您有一个很长的 Composer 会话,其中包含需要引用的重要上下文时
    • 当您开始一个新的但相关的任务,需要保持连续性时
    • 当您需要分享上一次会议的推理或决定时
  3. 优势

    • 帮助保持对话的连续性
    • 避免重复之前的讨论
    • 方便引用历史决策和推理过程

这个功能对于处理复杂任务特别有用,因为它可以帮助您在不同会话之间保持上下文的连贯性,同时避免重复之前已经讨论过的内容。

3.15 - @Files

使用 # 选择文件,使用 @ 在与 AI agent 聊天时进行上下文控制

使用 # 后跟文件名来关注特定文件。将其与 @ 符号结合,以实现精确的上下文控制。

3.16 - /command

使用 / 引用打开的编辑器选项卡,并在使用 AI agent 编写聊天时将其作为上下文添加

您可以键入 / 来快速引用打开的编辑器并将其添加为上下文

  • 打开编辑器 :当前打开所有编辑器选项卡
  • 活动编辑器 :视图中的所有编辑器选项卡。这通常发生在分割布局以显示多个编辑器时

实操:菜单和文档有些小的出入

  • “Add open files to context” : 是把所有打开的文件都添加到上下文
  • “Add active files to context” : 是把当前视图中的文件添加到上下文

4 - 忽略文件

了解如何使用 .cursorignore 和 .cursorindexingignore 在 Cursor 中控制文件访问和索引

概述

Cursor 提供了两个不同的忽略文件来控制文件的处理方式:

  • .cursorignore:尽最大努力从 AI 功能和索引中排除文件

  • .cursorindexingignore:仅控制为搜索和上下文索引哪些文件(与旧的 .cursorignore 相同)

.cursorignore

.cursorignore 文件会尽最大努力将文件从 AI 功能和索引中排除。这对于以下情况很有用:

  • 试图从 AI 访问和索引中排除敏感文件

  • 排除包含机密的配置文件

  • 限制对专有代码的访问

.cursorignore 中列出的文件将以最佳方式从 Cursor 的 AI 功能中排除:

  • 不包含在标签页和聊天请求中

  • 未包含在 AI 功能的上下文中

  • 未为搜索或上下文功能编制索引

  • 通过@-symbols 或其他上下文工具不可用

.cursorindexingignore

.cursorindexingignore 文件仅控制为搜索和上下文功能索引哪些文件。这提供了与旧的 .cursorignore 相同的索引控件。当您需要执行以下操作时,请使用此文件:

  • 从索引中删除生成的大型文件

  • 跳过二进制文件的索引

  • 控制代码库的哪些部分可搜索

  • 优化索引性能

重要提示:.cursorindexingignore 中的文件仍然可以作为上下文手动包含或通过 AI 功能访问-它们不会自动索引或包含在搜索结果中。

默认索引忽略文件

仅对于索引,除了在 .gitignore、.cursorignore 和 .cursorindexignore 文件中指定的文件外,默认情况下还忽略以下文件。请注意,这些默认文件仅适用于索引,而不适用于其他 AI 功能。

package-lock.json
pnpm-lock.yaml
yarn.lock
composer.lock
Gemfile.lock
bun.lockb
.env*
.git/
.svn/
.hg/
*.lock
*.bak
*.tmp
*.bin
*.exe
*.dll
*.so
*.lockb
*.qwoff
*.isl
*.csv
*.pdf
*.doc
*.doc
*.xls
*.xlsx
*.ppt
*.pptx
*.odt
*.ods
*.odp
*.odg
*.odf
*.sxw
*.sxc
*.sxi
*.sxd
*.sdc
*.jpg
*.jpeg
*.png
*.gif
*.bmp
*.tif
*.mp3
*.wav
*.wma
*.ogg
*.flac
*.aac
*.mp4
*.mov
*.wmv
*.flv
*.avi
*.zip
*.tar
*.gz
*.7z
*.rar
*.tgz
*.dmg
*.iso
*.cue
*.mdf
*.mds
*.vcd
*.toast
*.img
*.apk
*.msi
*.cab
*.tar.gz
*.tar.xz
*.tar.bz2
*.tar.lzma
*.tar.Z
*.tar.sz
*.lzma
*.ttf
*.otf
*.pak
*.woff
*.woff2
*.eot
*.webp
*.vsix
*.rmeta
*.rlib
*.parquet
*.svg
.egg-info/
.venv/
node_modules/
__pycache__/
.next/
.nuxt/
.cache/
.sass-cache/
.gradle/
.DS_Store/
.ipynb_checkpoints/
.pytest_cache/
.mypy_cache/
.tox/
.git/
.hg/
.svn/
.bzr/
.lock-wscript/
.Python/
.jupyter/
.history/
.yarn/
.yarn-cache/
.eslintcache/
.parcel-cache/
.cache-loader/
.nyc_output/
.node_repl_history/
.pnp.js/
.pnp/

文件格式

这两个文件使用与 .gitignore 相同的语法。以下是一些示例:

基本模式

# Ignore all files in the `dist` directory
dist/

# Ignore all `.log` files
*.log

# Ignore specific file `config.json`
config.json

高级模式

只在 app 目录中包含 *.py 文件:

# ignore everything
*
# do not ignore app
!app/
# do not ignore directories inside app
!app/*/
!app/**/*/
# don't ignore python files
!*.py

故障排查

ignore 文件的语法完全遵循 .gitignore。如果您遇到问题:

  1. 在搜索查询中将 “cursorignore” 替换为 “gitignore”
  2. 为类似模式检查 Stack Overflow
  3. 使用 git check-ignore -v [file] 测试模式以了解匹配

常见问题:

  • 模式相对于 ignore 文件位置进行匹配

  • 后来的模式覆盖了以前的模式

  • 目录模式需要一个尾随斜杠

  • 否定模式(!)必须否定以前的模式

5 - 模型上下文协议

了解如何在 Cursor 中添加和使用自定义 MCP 工具

什么是 MCP?

模型上下文协议(Model Context Protocol / MCP) 是一个开放的协议,它描述了应用程序如何向 LLMs 提供上下文和工具。可以将 MCP 看作 Cursor 的插件系统-它允许您通过标准化接口将 Agent 连接到各种数据源和工具,从而扩展 Agent 的功能。

要了解有关 MCP 的更多信息,请访问官方 MCP 文档,深入了解协议:

https://modelcontextprotocol.io/introduction

使用

MCP 允许您将 Cursor 连接到外部系统和数据源。这意味着您可以将 Cursor 与现有的工具和基础设施集成,而不必在代码本身之外告诉 Cursor 项目的结构。

MCP 服务器可以用任何可以打印到标准输出或服务于 HTTP 端点的语言编写。这种灵活性允许您使用首选的编程语言和技术堆栈非常快速地实现 MCP 服务器。

示例

  • 数据库: 允许 Cursor 直接查询数据库,而不是手动输入模式或自己操作数据。

  • notion: 从 notion 中读取数据以引导 cursor 实现功能

  • GitHub: 让 Cursor 创建 PR、创建分支、查找代码等

  • Memory: 允许 cursor 在您工作时记住和调用信息

  • Stripe: 允许 Cursor 创建客户、管理订阅等

疑问: 这些 example 在哪里啊?没有链接

架构

MCP 服务器是通过标准化协议公开特定功能的轻量级程序。它们充当 cursor 和外部工具或数据源之间的中介。

cursor 支持 MCP 服务器的两种传输类型:

  • stdio Transport

    • 在本地计算机上安装
    • 由光标自动管理
    • 通过标准输出直接通信
    • 仅限您在本地访问

    输入:Cursor 自动运行的有效 shell 命令

    对于 stdio 服务器,该命令应该是 Cursor 可以运行的有效 shell 命令。

  • SSE Transport

    • 可以在本地或远程运行
    • 由您管理和运营
    • 通过网络进行通信
    • 可以跨机器共享

    输入: 指向 Cursor 外部 MCP 服务器的 /sse 端点的 URL

    对于 SSE 服务器,URL 应该是 SSE 端点的 URL,例如 http://example.com:8000/sse

每种传输类型都有不同的用例,stdio 对于本地开发来说更简单,而 SSE 为分布式团队提供了更大的灵活性。

配置 MCP 服务器

MCP 配置文件使用 JSON 格式,结构如下:

// 该示例演示了使用 stdio 格式的 MCP 服务器
// Cursor 会自动为您运行该进程 
// 该示例使用 Node.js 服务器,使用 `npx` 运行
{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["-y", "mcp-server"],
      "env": {
        "API_KEY": "value"
      }
    }
  }
}
// 本例演示了使用 stdio 格式的 MCP 服务器
// Cursor 会自动为您运行该进程
// 该示例使用 Python 服务器,用 `python` 运行
{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["-y", "mcp-server"],
      "env": {
        "API_KEY": "value"
      }
    }
  }
}
// 本例演示了使用 SSE 格式的 MCP 服务器
// 用户应手动设置和运行服务器
// 可以联网,让其他人也能访问它
{
  "mcpServers": {
    "server-name": {
      "url": "http://localhost:3000/sse",
      "env": {
        "API_KEY": "value"
      }
    }
  }
}

env 字段允许您指定 MCP 服务器进程可用的环境变量。这对于管理 API 密钥和其他敏感配置特别有用。

配置位置

您可以将此配置放置在两个位置,具体取决于您的用例:

  • 项目配置

    对于特定于项目的工具,请在项目目录中创建 .cursor/mcp.json 文件。这允许您定义仅在特定项目中可用的 MCP 服务器。

  • 全局配置

    对于要在所有项目中使用的工具,请在 home 目录中创建一个 ~/.cursor/mcp.json 文件。这使得 MCP 服务器在您的所有 Cursor 中可用。

在 Agent 中使用 MCP 工具

Composer Agent 将自动使用 MCP 设置页面上的可用工具下列出的任何 MCP 工具(如果确定它们相关)。要有意地提示工具的使用,只需告诉代理使用该工具,通过名称或描述来引用它。

工具批准

默认情况下,当代 agent 要使用 MCP 工具时,它将显示一条消息,要求您批准。您可以使用工具名称旁边的箭头展开消息,并查看 agent 使用哪些参数调用工具。

Yolo 模式

您可以启用 Yolo 模式,以允许 agent 自动运行 MCP 工具,而无需批准,类似于终端命令的执行方式。阅读更多关于 Yolo 模式和如何启用它在这里 .

工具响应

当使用工具时,cursor 将在聊天中显示响应。此图像显示了示例工具的响应,以及工具调用参数和工具调用响应的扩展视图。

限制

MCP 是一个非常新的协议,仍处于积极的发展中。有一些已知的警告要注意:

  • 工具数量: 一些 MCP 服务器,或用户与许多 MCP 服务器活动,可能有许多工具可供 cursor 使用。目前,Cursor 只会将前 40 个工具发送给 agent。

  • 远程开发: Cursor 直接从本地机器与 MCP 服务器通信,可以直接通过 stdio 或使用 sse 通过网络。因此,当通过 SSH 或其他开发环境访问 Cursor 时,MCP 服务器可能无法正常工作。我们希望在未来的版本中改进这一点。

  • mcp 资源:MCP 服务器提供两种主要功能:工具和资源。今天,Cursor 中提供了工具,允许 Cursor 执行 MCP 服务器提供的工具,并在其后续步骤中使用输出。但是,Cursor 中还不支持资源。我们希望在未来的版本中添加资源支持。