用 Devin 和 MCP 打造你自己的 AI 数据分析师
Build Your Own AI Data Analyst | Cognition
Cognition 团队把 AI 软件工程师 Devin 接入数据库与资源的 MCP,训练出一个 24/7 在线的 AI 数据分析师,让原本需要数天甚至数周的分析问题缩短到几分钟。Devin 能检索产品代码、埋点事件、ETL 管道和数据模型,并通过运行 SQL 验证结论,还支持从 Slack 发起分析、结果就绪后通知。团队已上线 MCP Marketplace,可安装数十个高质量 MCP 集成,也可用 "Add Your Own" 添加未收录的 MCP。
正文
当前显示原文,中文全文译文尚未就绪。
Devin: the autonomous software engineer
Selecting seat
Devin’s computer
Flag enabled; mobile viewport on enterprise child org
Testing 3/12
0:24
Ensure compatibility across various screen sizes and maintain usability features
0:36
Incorporate accessibility guidelines to enhance user experience for all
0:24
Render in light and dark themes
Data retrieval optimization
1:30
Offline data storage enhancement
2:15
Real-time analytics integration
3:00
User interface optimization
Tests end to end on its own computer
Devin spins up its own Windows, Mac, and Linux virtual machines as needed to build, test in its browser, and record itself clicking through what it built
Cognition Team August 2025 6 minute read
This post is the first in a two-part series on building AI data analysts with Devin and MCP. For a step-by-step guide, check out Part 2.
Introduction
Our #analytics Slack channel looks completely different than it did a year ago. Like most companies, we used to struggle with analytics. Even seemingly simple questions like "Why is enterprise plan revenue spiking for this cohort?" led to ping chains of doom.
Getting answers often took days or weeks. Now, it takes minutes. What changed? We trained our own 24/7 on-demand data scientist.
Previously, knowledge fragmentation made it extremely difficult to trace data anomalies back to their source or ask new questions. This fragmentation is common across organizations, with specialized knowledge scattered across different teams:
Product Engineers develop feature X, and add instrumentation of events and metrics based on business logic; Data Engineers manage complex data pipelines and ETL processes to make data available in data warehouses, applying post-processing logic and consolidating data into more easily digestible views; Data Scientists and Analysts consume this data to gain insights and build predictive models; BI / Marketing / Growth team members consume this data to build advanced reports, view trends, measure campaign performance, etc; Finance departments crunch numbers on cost, revenue, margin reports, etc
We solved this issue by training our own AI data analyst by connecting Devin, our AI software engineer, to MCPs for our databases and resources. This way, knowledge fragmentation is no longer an issue, since the data team can train one AI data analyst and set it up for the rest of the team to use. Our team can now answer questions faster, allowing the data team to focus on more complex questions and projects.
Why Train Your AI Software Engineer as a Data Scientist?
Devin is an AI software engineer. This means that Devin can understand both our codebase and our data. Devin:
Excels at codebase understanding (try it at deepwiki.com!); Can search through all of our product code, instrumented events, ETL pipelines, and the final transformations and data models; Can pick up Knowledge about our company and products from past sessions
While other SQL‑focused tools only see final results materialized in our tables, context on how each column is actually computed is key when doing data analysis end‑to‑end.
Let’s say a product manager wants insights into feature adoption. They might not actually know the internals of the data schema, what events are available, where numbers come from, and which tables and columns to use. Devin, on the other hand, can rapidly search your entire codebase to find the best matches to answer the question, and can also verify what it found by running SQL queries over your data.
A non‑trivial data analytics question often involves back‑and‑forth querying and exploration: initial queries lead to follow-ups, validating insights with additional queries, creating time series plots or comparing across cohorts, etc.
Devin excels at supporting these long-running, iterative workflows: kick off analysis from Slack, get notified when results are ready, and seamlessly pull in teammates for verification or discussion when needed.
Here’s what our analytics channel typically looks like:
Technical Overview: MCP + Databases
MCP (Model Context Protocol) is an open protocol that enables AI agents like Devin to securely communicate with external tools and services. Think of it as a toolbox you can give to your AI agent to do its job.
MCP servers abstract away complexity by providing tools directly to agents, eliminating the need to manage intermediate steps. This means neither users nor agents need to set up direct connections or navigate complex infrastructure. Agents can focus on their primary tasks without getting lost in technical details, as the MCP handles securing connections, tool execution, and results processing behind the scenes. MCP servers give Devin superpowers!
We recently shipped the MCP Marketplace, making it easy to install and use dozens of high-quality MCP integrations for various tools and services. You can also install MCPs that are not in our marketplace yet using the "Add Your Own" option.
In the context of data analytics, MCP acts as a bridge between Devin and our company's databases and external services. At its core, MCP provides a standardized way for AI agents to use tools and access resources:
Access databases securely: Connect to our data warehouse without exposing credentials directly to the agent; Explore schemas: Understand table structures, relationships, and data types; Execute queries: Run SQL against our database or data warehouse with proper permissions; Process results: Format and visualize query outputs in an agent-optimized way; Share easily verifiable results: Include links to dashboards, visualizations and interactive results which you can easily edit and verify
This flow can be visualized in the following diagram:
What makes this model so powerful is that all we need to do is connect Devin to MCPs for our databases and resources. And because we can leverage Devin's brainpower, we can often trust that Devin will figure out what tools to use and how to use them. We don't need to define workflows for Devin to use.
In a real-world scenario, Devin might do several exploratory SQL queries before a conclusion is reached and finally shared with the user. We will explore some examples below.
Real-World Analytics Workflows
Let's say we just launched a new feature and want to understand its impact on users. We can ask Devin to help us analyze the data.
Notice that there’s no need to specify details like where to pull the data from. Devin already knows the codebase and can find what it needs. After a few minutes, Devin responds on Slack:
Devin can also help us visualize the Neon user engagement data alongside reliability metrics pulled from Sentry.
Importantly, we can quickly verify Devin’s work. Devin provides the final query for us to audit, build on top of, and run in Neon ourselves to verify.
This type of work is now repeated dozens of times every day across our company. If you assume that every question would take an hour to answer, we estimate that it would take a data team 150+ hours per month to do this work manually. With Devin, we can do it in minutes.
Beyond Basic Queries
Devin can also go beyond basic queries and help you with more complex tasks. Here are some examples from our company and other enterprises:
Data warehouse exploration
Devin can map your database structure, navigate complex schemas and help you identify the right data sources for your analysis
Implementing schema changes
After some exploratory data analysis, you can ask Devin to implement structural improvements to your data organization.
Find Data Gap
This helps identify potential data gaps or inconsistencies before they can negatively impact your business decisions.
Data segmentation
Understand what the biggest contributors and groups are for your particular use case. Devin can slice data in meaningful ways to reveal hidden patterns and opportunities.
Understanding Feature Adoption
Devin can analyze usage patterns to identify which features are most valuable to your users and which might need improvement or promotion.
Forecasting
Devin can apply time-series forecasting techniques to your historical data, helping you predict future metrics and make data-driven strategic decisions.
Getting Started
For instructions and tips on how to create an AI data analyst for your team:
Cognition Team August 2025 5 minute read
In Part 2, we'll go over the details of how we built Devin into our own AI data analyst. Here's what we'll cover:
A quick start guide to create an AI data analyst; An example MCP configuration for a common database (PostgreSQL); Knowledge configuration examples to help your AI understand your data; Troubleshooting help if you get stuck
Before you begin
Before we dive into specifics, it's worth mentioning that having a legible and structured data setup is strongly recommended for using Devin as an AI data analyst. It's impossible for anyone, let alone an AI, to understand your data if it's not structured in a way that's easy to parse and understand. In our case, we use DBT, which allows us to represent our infrastructure as code and version control our data models and pipelines.
Mapping your data
This will allow you to:
Understand your data better, including what MCPs you may need to install to access your data; Provide Devin with the Knowledge it needs to be effective
Quick Start Guide
Check out the MCP Marketplace and install the integrations for your particular databases and resources, or choose “Add Your Own” if what you need isn’t in our marketplace; Configure your DB credentials; Click “Use MCP” to start your first session. You can use our default prompt or ask for something relevant to your use case; Add Knowledge that Devin should use when doing data analysis. Remember to attach a macro to the Knowledge (e.g. !analytics) so that you can conveniently invoke the Knowledge in your prompts
We've made it easy to connect Devin to your company's data. Devin is set up with Google's MCP Toolbox for Databases, and fully supports all major databases out of the box, including PostgreSQL, Firestore, Looker, and SQL Server. We're adding full support for the long tail of databases soon. In the meantime, you may need to add the appropriate credentials file to Devin's machine for a small number of databases (select “Modify repo setup” on any repo, and add the credentials file to the machine image).
Additionally, we built and open-sourced an MCP server for Metabase. You can find the code here. It has 80+ tools available for general database exploration as well as finding, creating, and answering questions about objects in Metabase including Dashboards, Cards, and Queries.
Below, we walk through a step-by-step example of how to configure a Supabase hosted PostgreSQL database.
Step 1: Find the database relevant to you in the MCP Marketplace
Navigate to Settings > MCP Marketplace; Click on the “Databases” pill to filter to just database MCPs; Click into the relevant database. In this example, we’ll set up the PostgreSQL MCP
Step 2: Find your database connection details
This step will differ based on your specific setup.
In our example we’re setting up a Supabase PostgreSQL database:
Navigate to the relevant Supabase project; Click “Connect” at the top of the screen; Copy the connection details. The ones you’ll need for PostgreSQL are:
POSTGRES_HOST (e.g. db.xyz.supabase.co); POSTGRES_DATABASE (e.g. postgres); POSTGRES_USER (e.g. postgres); POSTGRES_PASSWORD; POSTGRES_PORT (e.g. 5432)
Step 3: Configure and enable the MCP
Fill in the relevant connection details in the MCP server page in Devin; Click “Enable” at the bottom of the page
Step 4: Test the connection
Click “Test listing tools” to test that listing tools works successfully. If successful, the UI should show the list of available tools:; Click “Use MCP” to start your first session
Common Errors & Tips:
network is unreachable : Verify your host and port settings; connection refused : Ensure that you’re using the correct pooler type and port
Once you’ve enabled the MCP, you can start using it right away. You can use our default prompt or ask for something relevant to your use case!
Knowledge configuration example & tips
While having your entire codebase in context is helpful, much relevant knowledge exists outside of code. It may reside in Notion, Confluence, or in the minds of your domain experts. Devin offers programmable Knowledge you can add to equip it with the context it needs for data analysis.
Add Knowledge in Settings > Knowledge. Tip: Attach a macro (e.g. !analytics) to Knowledge so your team can quickly invoke it by including the macro in any message (highly recommended). Devin will automatically receive the complete Knowledge contents when the macro is invoked.
The option to add a macro is at the very bottom of the Knowledge creation page:
Most data questions at Cognition begin by invoking the !analytics macro:
This Knowledge might simply direct Devin to relevant sources and documentation, outline your preferred best practices, or specify how to format results.
In our case, we point Devin to our analytics repo Readme.md file, which provides a comprehensive overview of our structure. We also instruct Devin to include a direct link to our visualization platform (Metabase) alongside any data insights. This allows users to immediately explore the underlying data, tweak SQL queries, and verify Devin’s work. We share an example below:
Tips:
While not required, we recommend configuring SQL/dbt context via a repo. This tends to help Devin more quickly acquire the necessary context; Set Devin up to include links to a playground where users can quickly run Devin's queries themselves. This makes it much easier to validate and build on top of Devin's work. Within the next couple of days, we'll be adding a tool to the Metabase MCP which allows Devin to easily return links to the Metabase playground with a sql query pre-populated
We'd love to help!
Stuck or have questions? Email us at support@cognition.ai with your Devin organization name and a link to this blog post.